From: rogerd <gre...@gm...> - 2010-08-20 09:57:36
|
thanks fadh, I think my problem is within the video source. does the libcam.c auto detect video sources? ("/dev/video0") or do i have to specify the video input? and if so.. im sorry for asking too many question but would you quickly brief me through how to do? fadh_japan wrote: > > Dear rogerd, > > the code A.toIplImage(frame) did just that. It translate the data from > v4l2 to IplImage. You can actually see the picture by adding cvShowImage. > Here the full code: > > #include <stdio.h> > #include <stdlib.h> > #include "cv.h" > #include "highgui.h" > #include "libcam.h" > > int main() > { > IplImage *frame=cvCreateImage(cvSize(160, 120), 8, 3); > > //initialize camera > Camera A("/dev/video0", 160, 120, 30); // width=160 , height=120, fps=30 > > for (i=0;i<99;i++) > { > while(A.Get()==0) usleep(10); // get the image > A.toIplImage(frame); // translate the image to IplImage > // from here you can use opencv > > // show the image > cvNamedWindow("Picture", 0); > cvMoveWindow("Picture", 300, 100); > cvShowImage("Picture",frame); > > // need to add this if not you would not able to see the > window. > // click any key to continue to the next frame > cvWaitKey(0); > } > return 0; > } > > The code gets the image from v4l2, translate to IplImage and show the > image for 99 times. Different image each time. > > > rogerd wrote: >> >> Dear fadh_japan, >> >> Thanks for your help, but your code didnt seem to output 'frame' of an >> IplImage data structure. >> did you display the frames everynow and then? thanks, >> >> please help, it would be highly appreciated >> >> >> -Rogerd >> >> >> >> >> fadh_japan wrote: >>> >>> What I did was using v4l2 directly instead of opencv command to capture >>> the image. The code I use was from http://code.google.com/p/libv4l2cam/. >>> Download and uncompress the v4l2stereo-1.047 and take two files from it. >>> That is libcam.h and libcam.c. Add the header file to the project. How >>> to use? I did it like this (code has been snipped) >>> >>> >>> #include <stdio.h> >>> #include <stdlib.h> >>> #include "cv.h" >>> #include "highgui.h" >>> #include "libcam.h" >>> >>> int main() >>> { >>> IplImage *frame=cvCreateImage(cvSize(160, 120), 8, 3); >>> >>> //initialize camera >>> Camera A("/dev/video0", 160, 120, 30); // width=160 , height=120, >>> fps=30 >>> >>> for (i=0;i<99;i++) >>> { >>> while(A.Get()==0) usleep(10); // get the image >>> A.toIplImage(frame); // translate the image to IplImage >>> // from here you can use opencv >>> } >>> return 0; >>> } >>> >>> >>> about the frame rate. By using cvCaptureFromCAM(0) and by using my >>> algorithm, I could only get a maximum framerate of 10.8 fps but now I >>> can get upto 25.0 fps. one down side. (In my TODO list) it seams that >>> the auto focus is gone. Need to fix this. Hope this help. >>> >>> >>> >>> >> >> > > -- View this message in context: http://old.nabble.com/OpenCV-Overo-Webcam-tp29394348p29490404.html Sent from the Gumstix mailing list archive at Nabble.com. |