Access webcam on Linux

Hi,

I’ve tried to get webcam working on Linux but I cannot build “CaptureBasic” sample, it throws

undefined reference to cinder::Capture::*

Have I missed installed some libraries or such?
If Capture in cinder doesn’t support Linux then is there any block which does the job? or any direction would be grateful!

Thanks in advance.

Ubuntu 16.04
Cinder 0.9.2dev

Here’s whole logs I’ve got

CMakeFiles/CaptureBasic.dir/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp.o: In function `CaptureBasicApp::setup()':
/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp:34: undefined reference to `cinder::Capture::start()'
CMakeFiles/CaptureBasic.dir/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp.o: In function `CaptureBasicApp::update()':
/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp:49: undefined reference to `cinder::Capture::checkNewFrame() const'
/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp:52: undefined reference to `cinder::Capture::getSurface() const'
/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp:55: undefined reference to `cinder::Capture::getSurface() const'
CMakeFiles/CaptureBasic.dir/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp.o: In function `CaptureBasicApp::printDevices()':
/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp:88: undefined reference to `cinder::Capture::getDevices(bool)'
CMakeFiles/CaptureBasic.dir/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp.o: In function `cinder::Capture::create(int, int, std::shared_ptr<cinder::Capture::Device>)':
/home/av/Documents/Cinder/include/cinder/Capture.h:67: undefined reference to `cinder::Capture::Capture(int, int, std::shared_ptr<cinder::Capture::Device>)'
CMakeFiles/CaptureBasic.dir/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp.o: In function `std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<cinder::Capture*>(cinder::Capture*)':
/usr/include/c++/5/bits/shared_ptr_base.h:578: undefined reference to `cinder::Capture::~Capture()'
CMakeFiles/CaptureBasic.dir/home/av/Documents/Cinder/samples/CaptureBasic/src/CaptureBasicApp.cpp.o: In function `std::_Sp_counted_ptr<cinder::Capture*, (__gnu_cxx::_Lock_policy)2>::_M_dispose()':
/usr/include/c++/5/bits/shared_ptr_base.h:374: undefined reference to `cinder::Capture::~Capture()'
collect2: error: ld returned 1 exit status
CMakeFiles/CaptureBasic.dir/build.make:114: recipe for target 'Debug/CaptureBasic/CaptureBasic' failed
make[2]: *** [Debug/CaptureBasic/CaptureBasic] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/CaptureBasic.dir/all' failed
make[1]: *** [CMakeFiles/CaptureBasic.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

According to this https://github.com/cinder/Cinder/issues/1434 there’s no support for video capture in Linux yet.
It depends on what you want to do, but there are some blocks that could help, like Cinder-Kinect.

Hi avseoul,

you can try to access the webcam using openCv, it’s pretty straight forward:

http://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture

Thanks for your insight @gabor_papp @hperigo

It sounds like a bit overkill to use such huge addons only for loading up the webcams though… I might give a shot to build a simple one. I’m not very familiar to c++ and OS stuff in depth so I might bother you guys and this thread a lot. :]

cool,

you might want to try this lib also:
https://int80k.com/libuvc/doc/

but to be honest I could not make it work the time I tried, I guess it was some linux permission issue.

Thanks @hperigo I’ll take a look!

I’ve made a very very simple webcam loader which just pass the stream buffer to gl_texture. I use v4l2 lib, I referred an example in their doc and many other thankful resources.

Current version has been only tested with my laptop (ubuntu 16.04 lts / mbp 2012 mid) and most likely it could be only working with my machine ha… and current version only takes YUYV and convert to RGB24, if your webcam doesn’t support such format then the app will just throw an error and crash.

If you are interested in taking this to the next level pls let me know. I would love to see and learn from it!

https://github.com/avseoul/ci_v4l2_webcam_loader

I didn’t realize that it’s consume a lot of fps until I tried to use this for my another sketch. =(

I assume that I could update the buffer in another thread and pass to the texture in main thread to fix the frame drops but, to be honest, I’m not 100% sure where the problem comes from and there might be something mistakes in my code that I made when I ported the example into the cinder.

I’m not very experienced programmer but I want to be and I’m trying =] so I would like to ask help those cinder gurus in this forum, can you guys point me where the problems are or direct me what to do to make this better and usable module for cinder on linux?

I appreciate in advance!