0

I recently worked on two things : receiving data from the serial port (TinyOS and seriallisten) and capturing frames from a webcam (OpenCV). Now I want to use both together. I want to use modify the video quality according to the rssi received on the serial port.

I've been told that I can create a program which creates thread that would call the methods I previously used : camcapture.c and seriallisten.c, but I don't know how to do this.

Can someone explain it ?

Thanks

dsolimano
  • 8,870
  • 3
  • 48
  • 63

1 Answers1

0

You should look int Boost Threads. There are examples on the web on how to create a program and use Boost Threads to call either a class method or a non-class static method.

About using C++ library in C code, this stackoverflow post may be helpful. I guess using extern scope operator is the magic here. C++ cross-compiler is designed using C, so backward conversion is not impossible.

If you hit success in using C++ into C Wikipedia listed these for Multithreading libraries for C++. I guess it is worth visiting those and see what is good. Boost is still the best IMPO.

P.S. You should checkout intel's Threading Building Block TBB too. They are quite good and simple. Open source projects such as OpenCV uses tbb for their multithreaded class ops. the link is here

Community
  • 1
  • 1
ha9u63a7
  • 6,233
  • 16
  • 73
  • 108
  • Thank you, but I see it is a c++ library, can it also be used in c or do I need to change my code to write it all in c++ ? – user2553358 Jul 05 '13 at 10:43
  • @user2553558 You have got to remember that C++ doesn't have its own Thread library and therefore, uses the micrsoft/boost/POSIX implementation of C threads for C++ (using possibly `extern` scope operator). I guess you need to "Reverse Engineer" those to tailor to your needs. I would still recommend using some thread tutorial in C. I swear I have seen some C tutorial doing what you were asking in the question. I will update my answer with your concerns. – ha9u63a7 Jul 05 '13 at 12:23