Ask Your Question
0

Camera is not detected by opencv only ?

asked 2013-07-18 14:39:54 -0600

athulvijayan6 gravatar image

My laptop camera is working with cheese. it works even with ffmpg from terminal by

ffmpeg -f video4linux2 -r 25 -s 640x480 -i /dev/video0 out.avi

when i do

ls /dev/video*

, it shows

dev/Video0

so camera works.

but with opencv it doesn't detect at all. if i replace 0 with "some video file" in VideoCapture, the video runs. my code is


#include "opencv.hpp"
#include <iostream>

using namespace cv;
using namespace std;
int main() {

VideoCapture videoIn(0);
if (!videoIn.isOpened()) {
    cout << "yo, i ain't see no camera";
    return -1;
}

namedWindow("out", 1);
for (;;) {
    Mat frame;
    videoIn >> frame;
    imshow("out", frame);
    if (waitKey(30) >= 0)
        break;

}
return 1;
}

I use Sony C series laptop with Ubuntu 13.04 and opencv 2 in Eclipse IDE.

edit retag flag offensive close merge delete

Comments

Basically switch to openCV 2.4.6, tons of bugs with the video interface have been reported in the last versions and fixes have been written. Try first to get it to work in 2.4.6, if bug still persists, report back!

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-18 16:17:17 -0600 )edit
1

If you work with OpenCV 2.4.6, try 2.4.6.1. There is the error with v4l camera in 2.4.6, more details on opencv.org website.

AlexanderShishkov gravatar imageAlexanderShishkov ( 2013-07-18 16:22:55 -0600 )edit

i typed

pkg-config --modversion opencv

for knowing exact package version and it returned 2.4.6 if i run

dpkg -L libcv2

it says package 'libcv2' is not installed.

and one more concern. in my /usr/local/include there are two folders. one is opencv and another is opencv2. is it because i have somehow installed both opencv 1 and 2 ? and the program is getting compiled by opencv 1. ?

when i start a project in eclipse, i use usr/local/include/opencv2 as the include path in project properties.

athulvijayan6 gravatar imageathulvijayan6 ( 2013-07-19 07:56:35 -0600 )edit

you need the 2.4.6.1 package, not the 2.4.6 package...

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-19 08:17:57 -0600 )edit

Wow.. a truckload of thanks.. totally worked after installing 2.4.6.1.. thnx for the support..

athulvijayan6 gravatar imageathulvijayan6 ( 2013-07-19 09:45:21 -0600 )edit

Just like @Alexander Shishkov proposed :) Will post the solution as an answer. Please accept in order to make the topic look solved.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-19 12:53:28 -0600 )edit

@Alexander Shishkov, @StevenPuttemans I have also the same problem still with version 2.4.6.1 in Windows7. Actually the camera seems detected but as soon as it tries to turn on dies. Do you have any idea in this case?

Steve gravatar imageSteve ( 2013-07-21 19:28:11 -0600 )edit

Please create a new topic with all your system details, camera specifics, operating system, ... we will help you there. Don't hijack threads, because we want to stick to one problem in one topic only.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-07-22 00:58:19 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-07-19 12:55:09 -0600

@StevenPuttemans

Basically switch to openCV 2.4.6, tons of bugs with the video interface have been reported in the last versions and fixes have been written. Try first to get it to work in 2.4.6, if bug still persists, report back!

@Alexander Shishkov

If you work with OpenCV 2.4.6, try 2.4.6.1. There is the error with v4l camera in 2.4.6, more details on opencv.org website.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-18 14:39:54 -0600

Seen: 3,978 times

Last updated: Jul 19 '13