Ask Your Question
0

cvCaptureFromCAM(x) returning NULL, tried with X = 0,1, 2.. on raspberry pi2

asked 2015-12-01 19:32:34 -0600

pradeep_kb gravatar image
> #include <iostream>
> #include <opencv/cv.h>
> #include <opencv/highgui.h>
> 
> using namespace std;
> 
> char key;
> 
> int main() {
>   cvNamedWindow("Camera_Output",1);    
> //create a window     CvCapture* capture
> =cvCaptureFromCAM(0);                   // Capture using any camera, we can
> aslo use 0 as a parameter if we are
> using single camera.  if(capture ==
> NULL)         {           printf("cannot open
> camera#n");           return -1;      }
>   while(1){                            
> //creating any infinite loop for live
> streaming
>           IplImage* frame = cvQueryFrame(capture);                
> //capture image frames from camera
>       cvShowImage("Camera_Output",frame); 
> //show image frames on created window
>       key = cvWaitKey(10);                
> //Capture keyboard storke
>       if(char(key) == 27){
>                   break;      }   }       cvReleaseCapture(&capture);          
> //Release capture Image
>   cvDestroyWindow("camera_Output");    
> //Destroy Window
> 
>   return 0; }

please advice

edit retag flag offensive close merge delete

Comments

1
  • DO NOT USE OPENCV'S C_API (and please, don't argue)
  • try -1 for the id
  • cerr << getBuildInformation() << endl; and see (show us), what's under the Video IO section there. (did you build with v4l, ffmpeg and such ?)
berak gravatar imageberak ( 2015-12-02 00:59:34 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-02-24 07:47:16 -0600

Hi, I have this problem. I use cerr << getBuildInformation() << endl, result: General configuration for OpenCV 3.1.0 ===================================== Version control: unknown

Platform: Host: Linux 3.19.0-47-generic x86_64 CMake: 2.8.12.2 CMake generator: Unix Makefiles CMake build tool: /usr/bin/make Configuration: RELEASE

C/C++: Built as dynamic libs?: YES C++ Compiler: /usr/bin/c++ (ver 4.8.4) C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG C Compiler: /usr/bin/cc C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG Linker flags (Release):
Linker flags (Debug):
Precompiled headers: YES Extra dependencies: Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test Qt5::Concurrent Qt5::OpenGL /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libtiff.so /usr/lib/x86_64-linux-gnu/libjasper.so /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so dc1394 avcodec avformat avutil swscale dl m pthread rt /usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so 3rdparty dependencies: libwebp

OpenCV modules: To be built: core flann imgproc ml photo video imgcodecs shape videoio highgui objdetect superres ts features2d calib3d stitching videostab Disabled: world Disabled by dependency: - Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz

GUI: QT 5.x: YES (ver 5.2.1) QT OpenGL support: YES (Qt5::OpenGL 5.2.1) OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so) VTK support: NO

Media I/O: ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8) JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 62) WEBP: build (ver 0.3.1) PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50) TIFF: /usr/lib/x86_64-linux-gnu ... (more)

edit flag offensive delete link more

Comments

please delete this answer, and ask a question instead.

berak gravatar imageberak ( 2016-02-24 07:57:44 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-12-01 19:32:34 -0600

Seen: 550 times

Last updated: Dec 01 '15