You are not logged in.
I'm trying to do a simple opencv program, but it freezes my pc when I run it.
I just can't figure out what is causing this.
The program is:
#include <opencv/cv.h>
#include <opencv/highgui.h>
int main(int argc, char** argv) {
int i = 10000;
cvNamedWindow("img", CV_WINDOW_AUTOSIZE);
CvCapture* capture = cvCreateCameraCapture(-1);
IplImage* img;
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);
while(i--) {
img = cvQueryFrame(capture);
if (!img) {
break;
}
cvShowImage("img", img);
}
cvReleaseCapture(&capture);
cvDestroyWindow("img");
}
And I'm compiling it with
gcc -ggdb test.c `pkg-config --cflags --libs opencv`
Debugging with gdb I can see that the program makes my pc freeze in the line:
img = cvQueryFrame(capture);
In the line
CvCapture* capture = cvCreateCameraCapture(-1);
it throws:
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
Running with gdb there's another error that can be seen:
gdb a.out
GNU gdb (GDB) 7.4.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/maty/workspace/opencv/a.out...done.
(gdb) start
Temporary breakpoint 1 at 0x402384: file test.c, line 5.
Starting program: /home/maty/workspace/opencv/a.out
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Traceback (most recent call last):
File "/usr/share/gdb/auto-load/usr/lib/libgobject-2.0.so.0.3200.4-gdb.py", line 9, in <module>
from gobject import register
File "/usr/share/glib-2.0/gdb/gobject.py", line 3, in <module>
import gdb.backtrace
ImportError: No module named backtrace
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffe668) at test.c:5
warning: Source file is more recent than executable.
5 int i = 10000;
(gdb) s
6 cvNamedWindow("img", CV_WINDOW_AUTOSIZE);
(gdb) s
7 CvCapture* capture = cvCreateCameraCapture(-1);
(gdb) s
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
10 cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);
(gdb)
Thank you in advance for any help.
Offline
Hi,
Not sure exactly, but it could be a conflict issue.
I guess you already tested your webcam in another software.
Are you running some program that uses the webcam at the same time (e.g. skype)?
Offline
I've tested my camera in wxcam and it freezed my pc the same way. But I was assuming it was working on google hangout (as it did the last time I used it), which I tested now and it freezed my pc the same way. Cheese also doesn't work, but it doesn't freeze the pc (but I need to kill it to quit).
Perhaps my webcam is broken? I'm going to try from a live cd of another distro and then update this post if necessary.
Thank you.
Offline
It is maybe a driver issue. Did you check whether your webcam has specific drivers or is supported?
e.g. http://www.ideasonboard.org/uvc/
Offline