title: Raspberry pi 3 C++ Thread
body: <p>i have tried to accomplish using thread with Raspberry pi 3 with c++.</p>
  
  <p>My C++ code:</p>
  
  <pre><code>thread t1(&amp;salinecyObjectDT::colorBasedSegmentation, objDT, image, confParams.getHsvParams(), confParams.getSpectrum(), ref(binaryColorBasedFilter));                   
  t1.join();
  </code></pre>
  
  <p>objDT is a instance of a saliencyObjectDT class. And it's hpp file is;</p>
  
  <pre><code>void colorBasedSegmentation(const Mat&amp; image, const Mat&amp; params,int spectrum, Mat&amp; binaryFilter);
  </code></pre>
  
  <p>It's works well with my Windows machine but on Raspberry Pi 3 gives this error;</p>
  
  <pre><code>*In file included from /usr/include/c++/4.9/thread:39:0,
                   from /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:16:
  /usr/include/c++/4.9/functional: In instantiation of ‘struct std::_Bind_simple&lt;std::_Mem_fn&lt;void (salinecyObjectDT::*)(cv::saliency::StaticSaliencySpectralResidual&amp;, const cv::Mat&amp;, cv::Mat&amp;)&gt;(salinecyObjectDT, cv::saliency::StaticSaliencySpectralResidual, cv::Mat, std::reference_wrapper&lt;cv::Mat&gt;)&gt;’:
  /usr/include/c++/4.9/thread:140:47:   required from ‘std::thread::thread(_Callable&amp;&amp;, _Args&amp;&amp; ...) [with _Callable = void (salinecyObjectDT::*)(cv::saliency::StaticSaliencySpectralResidual&amp;, const cv::Mat&amp;, cv::Mat&amp;); _Args = {salinecyObjectDT&amp;, cv::saliency::StaticSaliencySpectralResidual&amp;, cv::Mat&amp;, std::reference_wrapper&lt;cv::Mat&gt;}]’
  /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:201:109:   required from here
  /usr/include/c++/4.9/functional:1665:61: error: no type named ‘type’ in ‘class std::result_of&lt;std::_Mem_fn&lt;void (salinecyObjectDT::*)(cv::saliency::StaticSaliencySpectralResidual&amp;, const cv::Mat&amp;, cv::Mat&amp;)&gt;(salinecyObjectDT, cv::saliency::StaticSaliencySpectralResidual, cv::Mat, std::reference_wrapper&lt;cv::Mat&gt;)&gt;’
         typedef typename result_of&lt;_Callable(_Args...)&gt;::type result_type;
                                                               ^
  /usr/include/c++/4.9/functional:1695:9: error: no type named ‘type’ in ‘class std::result_of&lt;std::_Mem_fn&lt;void (salinecyObjectDT::*)(cv::saliency::StaticSaliencySpectralResidual&amp;, const cv::Mat&amp;, cv::Mat&amp;)&gt;(salinecyObjectDT, cv::saliency::StaticSaliencySpectralResidual, cv::Mat, std::reference_wrapper&lt;cv::Mat&gt;)&gt;’
           _M_invoke(_Index_tuple&lt;_Indices...&gt;)
           ^
  CMakeFiles/SaliencyMapBasedDetection.dir/build.make:86: recipe for target 'CMakeFiles/SaliencyMapBasedDetection.dir/main.cpp.o' failed
  make[2]: *** [CMakeFiles/SaliencyMapBasedDetection.dir/main.cpp.o] Error 1
  CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/SaliencyMapBasedDetection.dir/all' failed
  make[1]: *** [CMakeFiles/SaliencyMapBasedDetection.dir/all] Error 2
  Makefile:83: recipe for target 'all' failed
  make: *** [all] Error 2*
  </code></pre>
  
  <p>And maybe it will be required, CmakeLists.txt looks like this;</p>
  
  <pre><code>*cmake_minimum_required(VERSION 2.8.4)
  project(SaliencyMapBasedDetection)
  
  set(SOURCE_FILES
      salinecyObjectDT.cpp
      salinecyObjectDT.hpp
      main.cpp)
  
  
  include(CheckCXXCompilerFlag)
  CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
  if(COMPILER_SUPPORTS_CXX11)
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  else()
         message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.$
  endif()
  
  find_package( OpenCV 3.2.0 REQUIRED )
  
  include_directories(${OPENCV_INCLUDE_DIR})
  
  add_executable(SaliencyMapBasedDetection ${SOURCE_FILES})
  
  target_link_libraries(
    SaliencyMapBasedDetection
    ${OpenCV_LIBS}
  )*
  </code></pre>
  
  <p>Edit: because of function is memberfunction should i use <strong>&amp;objDT</strong> while creating thread?</p>
  
  <p>Edit2: when i use cref and ref result looks like;</p>
  
  <pre><code>    /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp: In function ‘int main()’:
  /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:199:110: error: use of deleted function ‘void std::cref(const _Tp&amp;&amp;) [with _Tp = cv::Mat]’
        thread t1(&amp;salinecyObjectDT::colorBasedSegmentation, &amp;objDT, cref(image), cref(confParams.getHsvParams()), confParams.getSpectrum(), ref(binaryColorBasedFilter));
                                                                                                                ^
  In file included from /usr/include/c++/4.9/thread:39:0,
                   from /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:16:
  /usr/include/c++/4.9/functional:456:10: note: declared here
       void cref(const _Tp&amp;&amp;) = delete;
            ^
  /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:209:110: error: use of deleted function ‘void std::cref(const _Tp&amp;&amp;) [with _Tp = cv::Mat]’
        thread t1(&amp;salinecyObjectDT::colorBasedSegmentation, &amp;objDT, cref(image), cref(confParams.getLabParams()), confParams.getSpectrum(), ref(binaryColorBasedFilter));
                                                                                                                ^
  In file included from /usr/include/c++/4.9/thread:39:0,
                   from /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:16:
  /usr/include/c++/4.9/functional:456:10: note: declared here
       void cref(const _Tp&amp;&amp;) = delete;
            ^
  /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:242:110: error: use of deleted function ‘void std::cref(const _Tp&amp;&amp;) [with _Tp = cv::Mat]’
        thread t1(&amp;salinecyObjectDT::colorBasedSegmentation, &amp;objDT, cref(image), cref(confParams.getHsvParams()), confParams.getSpectrum(), ref(binaryColorBasedFilter));
                                                                                                                ^
  In file included from /usr/include/c++/4.9/thread:39:0,
                   from /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:16:
  /usr/include/c++/4.9/functional:456:10: note: declared here
       void cref(const _Tp&amp;&amp;) = delete;
            ^
  /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:248:110: error: use of deleted function ‘void std::cref(const _Tp&amp;&amp;) [with _Tp = cv::Mat]’
        thread t1(&amp;salinecyObjectDT::colorBasedSegmentation, &amp;objDT, cref(image), cref(confParams.getLabParams()), confParams.getSpectrum(), ref(binaryColorBasedFilter));
                                                                                                                ^
  In file included from /usr/include/c++/4.9/thread:39:0,
                   from /home/pi/Desktop/saliencyBasedDetection/saliencyDetection/main.cpp:16:
  /usr/include/c++/4.9/functional:456:10: note: declared here
       void cref(const _Tp&amp;&amp;) = delete;
            ^
  CMakeFiles/SaliencyMapBasedDetection.dir/build.make:86: recipe for target 'CMakeFiles/SaliencyMapBasedDetection.dir/main.cpp.o' failed
  make[2]: *** [CMakeFiles/SaliencyMapBasedDetection.dir/main.cpp.o] Error 1
  CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/SaliencyMapBasedDetection.dir/all' failed
  make[1]: *** [CMakeFiles/SaliencyMapBasedDetection.dir/all] Error 2
  Makefile:83: recipe for target 'all' failed
  make: *** [all] Error 2
  </code></pre>
  
  <hr>
  
  <p><strong>Solution: After i review my code and re-write with boost::thread in respect to boost::cref and boost::ref, it worked well...</strong></p>