c++ - C++11 Threads: Error passing a vector to a thread function -


I am working on a multi-thread middle function as part of a larger project. I have a lot of C ++ experience. The average work below should take a vector of 3-dimensional difference vectors, and return a 3-dimensional vector of inss where each entry input vector has the average value of all the entries in that index. So if the input is & lt; & Lt; 3,2,1>, & lt; 1,2,3>, & lt; 2,2,2 & gt; >, & Lt; 2,2,2 & gt; Return in This code will be used in real-time video implementation for the use of an average blur, so the desire to increase it.

  #include & lt; Thread & gt; # Include & lt; Iostream & gt; # Include & lt; Mutex & gt; #include & lt; Vector & gt; # Include & lt; Algorithm & gt; #include "median.h" // mutex to protect brugPixel (possibly not necessary) std :: mutex mtx; Std :: vector & lt; Integer & gt; Middle (const std :: vector & lt; std: vector & lt; int & gt; & amp; input;); {std :: vector & lt; Int & gt; BgrPixel; // Average BGR value std :: Thread first to store vector (thread_work, BRPPXL, input, 0); // thread for every color channel STD :: thread seconds (thread_convert, BRRPx, input, 1); Std :: Thread III (thread_convert, bgrPixel, input, 2); First.join (); Second.join (); Third.join (); Return BRPPXL; } Void thread_function (std :: vector & lt; int & gt; bgrpixel, const std :: vector & lt; std :: vector & lt; int & gt; and input 1, int channel) { Std :: vector & lt; Int & gt; Input = input 1 [channel]; // color channel std :: sort (input.begin (), copy input.end ()); Int size = input.size (); Get (size = 2 == 0) // median {mtx.lock (); BgrPixel [channel] = (input [size / 2] + input [size / 2 + 1]) / 2; Mtx.unlock (); } Other {mtx.lock (); BRPPxL [channel] = input [(size -1) / 2]; Mtx.unlock (); }}   

The compilation of the problem is on time, G ++ (and also bending) gives a fairly unpleasant error:

  g ++ -std = C ++ 11 -Pathred -o is included in the middle mean CCP file from /usr/include/c++/4.8.2/thread392, from median.cpp: 1: /usr/include/c++/4.8. 2 / Functional: Straight :: _ Bind_Cimal & lt; Void (* (std :: vector & lt; int & gt; std :: vector & lt; std :: vector & gt; interval & gt; & gt; int)) (Study:: Vector & Lt; int & gt; and const std :: vector & lt; std: vector & lt; int & gt; & amp ;, int) & gt; A: ???: [usl = Zero (& amp; std :: vector & lt; int & gt; Const std :: vector & lt; std :: vector & lt; int & gt; and, int); _Args = {std :: vector & lt; int, std :: extant & lt; int & gt; and; const std :: vector & lt; std: vector & lt; int, std :: allocation & lt ; Int> gt; & gt; std :: allocator & lt; std :: vector & lt; int, std :: allocator & lt; int & gt; & gt; & gt; & gt; & gt; int }] A median.cpp: 15: 58: Required from /usr/include/c++/4.8.2/functional:1697:61 here: Error: No type name is "Type" in standard class : Result_ph & lt; zero (* (std :: vector & lt; int gt; std :: vector & lt; std :: vector & gt; int & gt; & gt; ;, Int)) (std :: vector & lt; int & gt; const std :: vector & lt; std: vector & lt; int & gt; & amp;, & amp; int;) & gt; A ??? Typedef typename result_of & lt; _Callable (_Args ...) & gt; :: type result_type; ^ /usr/include/c++/4.8.2/functional:1727:9: error: someone Type name is not in "Type" in standard class: result_f & lt; Zero (* (std :: vector , std :: vector & lt; std: vector & lt; int & gt; & gt; int)) (std :: vector & lt; int & gt; & amp; const const std :: vector & lt; std: vector & lt; int & gt; & amp;, & amp;, int) & gt; One ???? _M_invoke (_Index_tuple & lt; _Indices ... & gt;) ^   

I have received a similar error message, but this is not particularly helpful in dealing with my problem. Any help Will be highly appreciated, I fully expect because I do not know what I am doing: p

Edit: Thread_Use and prototype for middle-hander header file from median.h

change

  std :: thread first (thread_for, bgrpixel , Input, 0);  

Live example:

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -