-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot capture images in OpenCV in UVC mode #11
Comments
Hi, You will not be able to get a color image with guvcview at this point. By redeclaring the used format to bayer you can create a correct image as the image data is identical when it comes to gray and bayer. Since guvcview does not know about all of this it will do some weird things that never will be able to succeed and (sadly) crash. Now to OpenCV: I have published an example here: |
Thanks! That code did help. The only modification I have to do for the DFK 42AUC03 camera was to replace |
Hello, one colleague of yours gave me your code and i have one basic question. I need from my camera to take pictures, not video... I thought i could change main.cpp and deleting "while()" command so that the snapframe() function be executed only one time. Am i right or i have to do sth else. Also i need to change exposure and gain so i write this part of code:
Is is correct???
is it correct or i have to change sth? |
Your setting code should work. The only thing you need to change is V4L2_CID_EXPOSURE to V4L2_CID_EXPOSURE_ABSOLUTE as all our cameras use that flag. From my experience imwrite should work as you expect. To save a single image it should suffice to call snap_image once. |
Thanks a lot for your reply. And i think i have a similar problem with guvcview aw i cannot see a color video, but only a greyscale. You said before i have to update drivers by using firmware dmk firmware. I think i have to do this from there: https://github.com/TheImagingSource/tiscamera/wiki/Getting-Started-with-USB-Cameras----> But can you tell me what is the correct firmware for DFK 23U274?
|
With snap_image you mean snapFrame() function am i right? |
Yeah, I meant snapFrame() sorry for that. USB-3.0 cameras do not require a firmware change. They work out of the box. |
Hello again, i have one more problem right now. |
Hello, could you send me the outputs of ls /dev, lshw and lsusb? Thank you in advance |
finally it was sth stupid.... i forgot "/" before dev..... I also have this for saving image ( i really don't know if there is an problem or there is sth else that i don't know )
|
It seems that the image is interpreted in a wrong RGB format, but with a compressed image it is hard to tell for sure. |
so i will have to change imwrite for having .bmp image? |
As far as I understand it, changing the file extension in the path parameter to .bmp should be sufficient. |
This is my modified code. imwrite( "/home/mdx/Desktop/image.jpg", mat_frame); Date: Mon, 15 Dec 2014 07:18:02 -0800 As far as I understand it, changing the file extension in the path parameter to .bmp should be sufficient. —
|
do you see an errors there? |
It looks like the wrong debayering mode is used to convert the picture to RGB. |
aha.... can explain to me a little bit more? Cause i cannot understand :/ |
The image data you get from the camera is in a RAW format, in this case black and white with a Bayer Pattern. The documentation for imwrite() suggests Mat::convertTo() and cvtColor() for this, thus I would suggest to read up on the usage of these functions. |
In main there was this line: cvCvtColor(pOpenCVImage,pColorCVImage,CV_BayerBG2RGB); |
This is the part of code in main that makes everything: start_capturing();
|
can you explain me why there is a double pic when i snap frame? |
A wrong resolution definitely explains the broken image. |
Stefan, can i have an exposure speed up to 10sec with DFK 23U274? |
Yes, Take care of the snap image time, as I already wrote by email to you |
Hello again, after some time. I want to ask you a critical question. I have DFK 23U274 and i tried it in windows with IC Capture 2.3. There i can snap images with Gain 9Db and Exposure time 2sec and 4,5 sec. In linux i use your C++. I saw from V4L2 API that i can have exposure time up to 30 secs, but in DFK 23U274 specs i read that i can use only up to 1/4sec . So i am wondering why in windows and in IC Capture 2.3 i can have a photo with 9DB and 2secs and in Linux i cannot. Can you help me pls with this final problem before my last tests? Marios Dimiou Yes, Take care of the snap image time, as I already wrote by email to you — |
Hi Unfortunately the spec of the DFK 23U274 is somewhat inexact about exposure times. 30 seconds is correct. Please excuse this. Stefan |
Goodmorning. In Linux i change exposure time at 7000 for example and i have timestamp. can i correct that somehow? I saw in V4l2 that exposure value of 10.000 is 1sec |
Hi I do not understand your question " In Linux i change exposure time at 7000 for example and i have timestamp. can i correct that somehow?" What is wrong, what should be corrected? When I query the available properties of the DFK 23U274, then I get: Property id 0x980913 name Gain min: 176, max: 1023 BR |
I have this part of code for exposure: but when i am trying to snap a photo i have timestamp message. and i don't have a photo.... Hi I do not understand your question " In Linux i change exposure time at 7000 for example and i have timestamp. can i correct that somehow?" What is wrong, what should be corrected? When I query the available properties of the DFK 23U274, then I get: Property id 0x980913 name Gain min: 176, max: 1023 Property id 0x9a0902 name Exposure (Absolute) min: 1, max: 300000 Property id 0x199e201 name Exposure Time (us) min: 100, max: 30000000 Property id 0x199e204 name Gain (dB/100) min: 0, max: 3032 Property id 0x199e208 name Trigger Mode min: 0, max: 1 Property id 0x199e209 name Software Trigger min: 0, max: 0 Property id 0x199e210 name Trigger Delay min: 0, max: 128 Property id 0x199e211 name Strobe Enable min: 0, max: 1 Property id 0x199e212 name Strobe Polarity min: 0, max: 1 Property id 0x199e213 name Strobe Exposure min: 0, max: 1 Property id 0x199e214 name Strobe Duration min: 0, max: 10000 Property id 0x199e215 name Strobe Delay min: -10000, max: 10000 Property id 0x199e216 name GPOUT min: 0, max: 1 Property id 0x199e217 name GPIN min: 0, max: 1 BR Stefan — |
Hello I suppose, your code is based on the V4l2 OpenCV sample, that we provided somewhere. I see a snaimage() call in one of the previous calls. I suppose, you want to set the exposure time to a longer value, so the image gets brighter. I do not see a relation to "timestamp" here. BR |
"Hello, i tried to work with IC Capture today and i had this message I reconnecting it and it is the same. PLs tell me that my camera isn't broken.... :/" What is "this message"? |
Hi, I have a 3.03 kernel and the same monochrome issue as described here. Can you please shed some more light on how to "reinterpret" these captures manually. Right now I have a bunch of *.mkv files that are all monochrome. I have tried converting them into RGB, avi using ffmpeg but couldn't get to extracting colored bmp out of those. Any help would be appreciated (good astronomical seeing is rare in my parts!). |
Mr filesync could you please give some more context? Or create a new issue? This thread here is quite long Stefan |
@mdxx, set up(ind fd,int exp,int gain){ //setting exposure //setting gain @TIS-Edgar , @TIS-Stefan , @TIS-Michael , any ideas? I created a struct for "var ctrl" with id and value but it didn't work. |
btw, I have a problem before the one above. I am getting images like this attached with this code: All I changed:
the raw file is also "broken", it's the "same image", but in grayscale. I am using raspberry pi. problem solved.. |
Answer to your first question: struct v4l2_control ctrl; v4l2_ioctl(fd, VIDIOC_S_PARM, &ctrl); Please see also at http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-ctrl.html The Raspberry PI is somewhat weak to handle the images at high frame rate of your DFK 42. Therefore, you must lower the frame rate. struct v4l2_streamparm setfps; I did not test this code on my own. |
it worked, thanks @TIS-Stefan. |
Hi @TIS-Stefan I have another important question: Do you have some C sample code Not c++ to get video stream? if you have not ,Do I need write it from V4L2 for my company embedded device(not need GUI to display the Live image,only get the data to memory )? Thank you very much for your reply very soon peter zhang |
Hi,
I have a DFK 42AUC03 camera and I want to grab images using OpenCV in Linux. Using euvccam-fw tool, I've updated the firmware to dmk42uc03_143.euvc and switched camera to UVC mode.
guvcview now gives a grayscale video stream in 1280x960. Here is log of running guvcview with --verbose switch: http://textuploader.com/kleq.
I couldn't find a way to get a color image in guvcview. Changing the Camera output to RGB3 caused guvcview to be closed with this error:
Also, I have a problem in capturing image using OpenCV. This simple code which capture image from the camera:
Gives the following errors:
I wonder if I should set some parameters before using VideoCapture object (I have tried settings resolution which didn't help and I couldn't find a way to set the pixel-format).
The text was updated successfully, but these errors were encountered: