![]() |
OpenCV C++ Bad file descriptor. USB Lifecam
Hello all, I am having an issue with the USB Lifecam and getting an image to an an openCV mat. My code works fine with an axis camera, but because ours broke a couple days ago I am trying to get the USB camera to work with the code. It opens the stream fine, but ends up with a width and height of zero. The error log is:
Code:
IM AM IN PROCESS IMAGE! Here is our code: Code:
// opens up the camera stream and tries to load itCode:
videoCapture.read(matOriginal);I'm really hoping someone else has had a similar issue because our team cannot afford another axis camera. Thanks, Drew |
Re: OpenCV C++ Bad file descriptor. USB Lifecam
Instead of videoCapture.read(matOriginal), try videoCapture >> matOriginal.
|
Re: OpenCV C++ Bad file descriptor. USB Lifecam
Quote:
|
Re: OpenCV C++ Bad file descriptor. USB Lifecam
Yes, we did try that and had the same effect.
|
Re: OpenCV C++ Bad file descriptor. USB Lifecam
I figured it wouldn't make a difference but you never know.
Would you link to all your vision code so I can take a look at it and play around with it? A fairly simple thing you could try would be to reinstall opencv through terminal: sudo apt-get remove --purge opencv sudo apt-get install libopencv-dev This won't give you gpu support (I don't think at least), but it's better to have something than nothing. Edit 1 I found your code on another thread. A thing I found was that you declare videoCapture, then inside a while loop you say: videoCapture = cv::VideoCapture(); Seems a little redundant. I'm not sure this is the cause to your error or not. Moving on to the next line, videoCapture.open("http://axis-camera.local/mjpg/video.mjpg"); isn't wrong, but it may be incorrect to have it in a while loop.... Edit 2 I just tested calling .open(0) in a while loop. While it did run, it ran at <1fps. I also tested having videoCapture = cv::VideoCapture(); inside a while loop too, and all it did was further bog down the program. Could you run in debugger mode and let me know which line is causing the error? Edit 3 Giving this a little more thought: I am not rehearsed in IP cameras, so this could be completely off, but... Would you test the following code for me? http://pastebin.com/6vrLBVtE |
Re: OpenCV C++ Bad file descriptor. USB Lifecam
Yes. I will test it tonight. Thank you for all the help.
I just tried the code you posted and it did not work. This was the error I got. Code:
VIDIOC_REQBUFS: Cannot allocate memory I'm pretty sure it connects to the camera find but it grabs an empty frame for some reason. Thanks. |
Re: OpenCV C++ Bad file descriptor. USB Lifecam
Also, it works fine with the axis camera and connects, just not the usb. But, we cant use the axis camera because it broke a couple of days ago.
|
Re: OpenCV C++ Bad file descriptor. USB Lifecam
How about just opening the camera using :
cv:VideoCapture videoCapture(0); That should be enough to open the camera and use it. All of the other stuff is just extra steps that could go wrong. There's a simple example at http://docs.opencv.org/2.4/modules/h...videocap ture which should just work if you want to rule out the rest of the code being the problem. |
Re: OpenCV C++ Bad file descriptor. USB Lifecam
I tested out the example code and it still says bad file descriptor still. I have the most simple code and still the same error.
Here it is: Code:
#include <stdio.h> |
Re: OpenCV C++ Bad file descriptor. USB Lifecam
Alright, I got the USB camera working. I reimaged the roboRIO, installed opencv 3.0 on the roboRIO and now it works! Thanks to the robotpy who helped me get this working and their repository with opencv code.
Their code is here:https://github.com/robotpy/roborio-opencv |
| All times are GMT -5. The time now is 01:28. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi