Powered by Blogger.

Monday, November 3, 2008

Tag: , , , , , , ,

OpenCV More with cameras.


In last tutorial we learn how to get frames of our camera, now we go to learn some basic OpenCV functions to work with our captured frames or video. There is nothing special, but it's the first steps to introduce to work with OpenCV

Imagine we want create a basic OpenCV program that get a video o camera capture and process the images to get a binary image difference between actual frame and last frame.

Then we have a actual image, lastImage, diffImage where we store the difference images, and the bitImage result that are IplImage instance.
IplImage* image;
IplImage* lastImage;
IplImage* diffImage;
IplImage* bitImage;

Whe need create these variables and initialize with cvCreateImage, this function create and allocate in memory the structure and headers of our image, this function need as attribute image size, depth and number of channels. We get frame as reference to initialize the variables.
image=cvCreateImage(cvSize(frame->width,frame->height),frame->depth,1);

The frame whe get sure is a RGB image, but we go to working with gray level images the we need conver captured frame to Gray Level. The cvCvtColor conver color spaces of image to another and is defined:
void cvCvtColor( const CvArr* src, CvArr* dst, int code );

src is the source 8-bit (8u), 16-bit (16u) or single-precision floating-point (32f) image. dst is the destination image of the same data type as the source one. The number of channels may be different. And code is color conversion operation that can be specified using CV_<src_color_space>2<dst_color_space> constants

cvCvtColor(frame, image, CV_BGR2GRAY);

We can get a new copy in memory of image withcvCloneImage
lastImage=cvCloneImage(image);

To get the image differences we use cvAbsDiff function, to get absolute diference between images:
cvAbsDiff(image,lastImage,diffImage);

The function definition
void cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst );

Where src1 is the first source array. src2 is the second source array, and dst is the destination array.
Then to finish we only need get a threshold of image, and we do it with cvThreshold function
cvThreshold(diffImage,bitImage,tr,255,CV_THRESH_BINARY);

And this function have this definition:
double cvThreshold( const CvArr* src, CvArr* dst, double threshold,
double max_value, int threshold_type );

Where src is source array (single-channel, 8-bit of 32-bit floating point), dst is destination array; must be either the same type as src or 8-bit, threshold is the threshold value, max_value is the maximum value to use with CV_THRESH_BINARY and CV_THRESH_BINARY_INV thresholding types, and threshold_type is thresholding type
This is the main loop program:
for(;;){
IplImage* frame = 0;
int c;

frame = cvQueryFrame( capture );
if( !frame )
break;
//If is the first frame
if(!image){
//Create image header same as frame but with 1 channel to gray
image=cvCreateImage(cvSize(frame->width,frame->height),frame->depth,1);
bitImage=cvCreateImage(cvSize(frame->width,frame->height),frame->depth,1);
}
//Convert frame to gray and store in image
cvCvtColor(frame, image,CV_BGR2GRAY);

//If is the first frame
if(!lastImage){

//If no lastImage clone actual image;
lastImage=cvCloneImage(image);
}
if(!diffImage){
//Create image header same as frame but with 1 channel to gray
diffImage=cvCreateImage(cvSize(frame->width,frame->height),frame->depth,1);
}

cvShowImage( "CamSub", frame );
//Differences with actual and last image
cvAbsDiff(image,lastImage,diffImage);
//threshold image
cvThreshold(diffImage,bitImage,tr,255,CV_THRESH_BINARY);
//Change datas;
lastImage=cvCloneImage(image);

cvShowImage("CamSub 1",bitImage);

c = cvWaitKey(10);
if( (char) c == 27 )
break;
}

Demo Source

About David Millán Escrivá

David completed his studies in Universidad Politecnica de Valencia in IT with a Master's degree in artificial intelligence, computer graphics, and pattern recognition, focusing on pattern recognition and Computer Vision. David has more than 15 years of experience in IT, with more than ten years of experience in Computer Vision, computer graphics, and pattern recognition, working on different projects and start-ups, applying his knowledge of Computer Vision, optical character recognition, and augmented reality. Co-Author of two OpenCV books and reviewer of few more.

99 comments:

  1. hi ,
    i copy the code and compile it .
    during runtime i get an error at line
    "cvCvtColor(frame, image, CV_BGR2GRAY);"

    mybe it because cvCvtColor is accept CvArr and not
    IplImage?

    how do i convert between thus two structure ?
    IplImage -> CvArr

    Thanks,
    Reut.

    ReplyDelete
  2. HI Reut, What is the error you have, when you pass a IplImage to a CvArray Function hi convert automatically between IplImage to CvArray.

    You copy my code or download the demo source?

    Post your error in pastebin and i can see it.

    ReplyDelete
  3. Hi! I could get your code running ok (my camera would whine on reporting FPS so I commented that).

    I'm under the impression that there is a slight memory leak -- Add "cvReleaseImage(&lastImage);" between //Change datas;
    and
    lastImage=cvCloneImage(image);

    Like this

    //Change datas;
    cvReleaseImage(&lastImage);
    lastImage=cvCloneImage(image);

    Thanks a lot for your tutorial, it's given me quite a kickstart on another project :)

    ReplyDelete
  4. Thanks for advice, i go to test and change source code.

    ReplyDelete
  5. I have two images of the same size. They are obtained like this:
    img1 = cvLoadImage( ... );
    and
    img2 as cvResize( img_src, img2, ... );

    when I tried
    cvNorm( img2, img1, CV_L2, NULL );

    I am getting an Error;
    " OpenCV error: Assertion failed (a.type()==b.type() && a.size()==b.size()) in norm, .... "

    both have the same size.

    Can you help me...

    ReplyDelete
  6. You sure get this error because the img1 and img2 are not same type, this is, no are same depth, or sure, one is a 8 unsigned char and other is a 32 float data. See the img1 and 2 creation.

    ReplyDelete
  7. Thank you.. but, I didnt understand you fully. I see that both are IplImage*. But, were are these '8 unsigned char' and '32 float' set in the creation of the images?

    If so, is there any way to make these two images the same type? Some convertion operation or so...

    Do I have to first create the images using cvCreateImage?

    both images are binary images.

    Thank you

    ReplyDelete
  8. Ok. I solved the problem. thanks a lot.

    I created img1 as
    img1 = cvCreateImage( 'FileName', CV_LOAD_IMAGE_GRAYSCALE );

    Now img1 and img2 are of the same type and I can use cvNorm on them.

    rku

    ReplyDelete
  9. can u pls help me....i want to store the frames which i m capturing in one loop....the problem is that in cvSaveImage function, every time the new frame is saved in the same filename(overwriting occurs which is obvious)....in short..i am unable to store frames in different files such as frame1, frame2, frame3, and so on for subsequent frames...

    thanks in advance.....

    ReplyDelete
  10. shiva, try something like this:

    int index = 0;

    while (...){
    frame = cvQueryFrame( capture );
    stringstream ss("image");
    ss<<index++<<".bmp";
    cvSaveImage(ss.str().c_str(),frame);

    ...
    }

    Thanks Damiels for your posts!

    ReplyDelete
  11. Thanks Juan Pablo for respond the question ;)

    ReplyDelete
  12. I tried Juan Pablo's algorithm, but cannot get it to work. The errors are:

    error C3861: 'ss': identifier not found
    error C2228: left of '.str' must have class/struct/union error C2228: left of '.c_str' must have class/struct/union
    error C2228: left of '.bmp”' must have class/struct/union
    error C2146: syntax error : missing ';' before identifier 'ss'
    error C2065: 'stringstream' : undeclared identifier
    error C2065: '”image”' : undeclared identifier c
    error C2065: '”' : undeclared identifier

    can anyone identify the problems?

    ReplyDelete
  13. are you compiling with g++ or gcc?
    Instead you can use this option.

    int index = 0;
    char file[255];

    while (…){
    frame = cvQueryFrame( capture );
    i++;
    sprintf(file,"image_%d.jpg",i);
    cvSaveImage(file,frame);


    }

    ReplyDelete
  14. Maybe I'm better off telling everyone what I'm trying to do. I'm using OpenCV to do motion detection by getting the video's images, process it to get its threshold image and then do motion history. Problem is, I'm new to this and I don't quite understand how to grab two images from the video (previous and next). I've tried the codes here but they don't seem to work.

    ReplyDelete
  15. Next? If you have the actual frame, you can't get the next frame, you can't get the future.

    But if you want get a mhi, you must get the t-2, t-1 ant t frames, where t is the actual frame. Then you only need get this three images

    Then you need 3 variables
    IplImage *f2, *f1, *f;

    and in your code
    initialize getting 3 images
    f2=cvQueryFrame(capture); //t-2
    f1=cvQueryFrame(capture);//t-1
    f=cvQueryFrame(capture);//Actual frame
    And in the loop you only need actualice images and your mhi, each new frame, because new t
    while(..){
    cvCopy(f1, f2,0);//Copy frame 1 to frame 2
    cvCopy(f,f1,0);
    f=cvQueryFrame(capture);
    //create your mhi with f,f1 and f2
    }

    ReplyDelete
  16. After going through your algorithm, I finally understand how the flow goes..I tried it on my program, but the frame grabbing doesn't work.

    The flow is supposed to be like:
    No loop: f2-A, f1-A,f-A
    1st loop:f2-A, f1-A,f-B
    2nd loop:f2-A, f1-B,f-C
    3rd loop:f2-B, f1-C,f-D....and so on...

    But displaying the pics after each loop, I found out that it was actually:
    No loop: f2-A, f1-A,f-A
    1st loop:f2-B, f1-B,f-B
    2nd loop:f2-C, f1-C,f-C

    anyway the whole f, f1 and f2 just grab the same frame each time, so the thresholding doesn't work.

    BTW I'm using Microsoft Visual Studio 2005 VC++. The new each-frame saving algorithm works on my program so thanks for that.

    ReplyDelete
  17. Please ensure this order of calls:

    cvCopy(f1, f2,0);//Copy frame 1 to frame 2
    cvCopy(f,f1,0);
    f=cvQueryFrame(capture);

    ReplyDelete
  18. Hi,
    I'm wanna do the same but with this little program:

    #include "stdafx.h"
    #include "highgui.h"
    #include "cv.h"

    int main( int argc, char** argv )
    {
    CvCapture* capture = cvCreateCameraCapture(0);
    IplImage* frame;
    IplImage* framePast;
    IplImage* frameDiff;
    cvNamedWindow( "video", CV_WINDOW_AUTOSIZE );
    framePast = cvQueryFrame( capture );
    frameDiff = cvQueryFrame( capture );
    char c = cvWaitKey( 40 );
    while (1)
    {
    frame = cvQueryFrame( capture );
    if( !frame ) break;
    cvAbsDiff( frame, framePast, frameDiff );
    char c = cvWaitKey( 40 );
    framePast = frame;
    cvShowImage( "video", frameDiff );
    c = cvWaitKey( 40 );
    if( c == 27 ) break
    }
    cvReleaseCapture( &capture );
    cvDestroyWindow( "video" );
    return 0;
    }

    Anyway, what I get, is a black window... WHY?

    Regards
    Alessandro

    ReplyDelete
  19. Alessandro you have a black image because you are doing the image difference with the same data, because when you do framePast=frame you assign the memory block of frame to framePast then when you do frame=cvQueryFrane(capture) you are getting same data in framePast

    You must use cvCloneImage for get only data.

    Regards David.

    ReplyDelete
  20. Thanks for you suggestion, but in the "while {..}" the second time after a "cvWaitKey(40)", a "frame = cvQueryFrame( capture );" is performed again takeing another frame, so the cvAbsDiff should has two different frames to subtract...

    ReplyDelete
  21. Yes but you are accesing to area image block, and if you read the opencv doc about cvqueryframe you can not modify or release this returned image...

    You must do a cvClone image.

    You can test easly the memoryblocks with a debugger...

    Regards.

    ReplyDelete
  22. Yeah, I tried and it works properly, I was just curious about that.
    Look, I have searched for that, but the online guide installed with the library are not so exhaustive.

    Regards

    ReplyDelete
  23. Alessandro, all you need of doc are here: http://opencv.willowgarage.com/documentation/index.html

    This is all we need of opencv documentation.

    Regards.

    ReplyDelete
  24. i'm tryin to import facedetector code as DLL into labview but image format in labview n openCV r different hence i'm trying code like below

    void facedet(CvArr* img1,double scale,CvRect* r[])
    //img passed in CvArr
    {

    IplImage* img=(IplImage*) img1;

    //further code ......

    }

    i dont think just typecasting will convert CvArr to IplImage please help to convert CvArr to IplImage

    ReplyDelete
  25. how to convert the cvRect in to cvArray

    ReplyDelete
  26. hi all

    can any one help me how to convert a AVI video into a no.of frames.

    thanks a million

    regards,

    ReplyDelete
  27. Thanks a million for ur replay damiles,
    its working...

    ReplyDelete
  28. hi damiles,

    i am presently using pyramid Lucas kanade for tracking a car in a video. My code is working but output video is in reversed .
    can you help me plz.

    ReplyDelete
  29. larun what you use finally?

    ReplyDelete
  30. damiles

    i change all set of CV_CVTIMG_FLIP param in 0
    cvConvertImage(frame, frame2_1C, 0);

    ReplyDelete
  31. Damiles,

    could u plz tell me which is best way in open cv to track a car in night video
    1.by color
    2.headlight
    3.number plate

    thanks ,
    Best Regrads,
    larun

    ReplyDelete
  32. try to use a infrared camera...

    ReplyDelete
  33. ya i read about infrared camera but it manufacturer of thermal imaging which is very expensive project.so,i want to track a car in normal camera video

    ReplyDelete
  34. hi damiles,

    i don't got any replay for you.
    do you have any code for tracking a car by color in open cv.

    Thanking You,
    Best Regards,
    larun

    ReplyDelete
  35. Sorry Larun for respond too later.

    I don't have any code for you but you can check this link about videosurvillance http://opencv.willowgarage.com/wiki/VideoSurveillance with this you can detect non background objects, then you can classify it's by color, type or similar.

    ReplyDelete
  36. Hi everybody
    I need to use the CvSaveImage for save an image in a folder different from the project one, because I need toshow it in a website using RoR.
    How can I save the image in another folder using Opencv

    Thanks

    ReplyDelete
  37. thanks damiles,

    is there any possible to track a specific car in a video by PLK in opencv/vc++.

    thanks a million for ue help.
    it is very usefull to my project damiles,

    Best Regards,
    larun

    ReplyDelete
  38. Hi larun, what do you mean with PLK, sorry my english is very bad and i'm spanish. I do not know all the abbreviations in English.

    ReplyDelete
  39. sorry damiles,

    PLK method Pyramidal Lucas Kanade

    ReplyDelete
  40. larun, i'm not a computer vision expert, i'm sure you know more about computer vision than me. With piramid lucas kanade plk you can obtain the optical flow of image, i'm sure you can track a car or all objects of image.

    How you can do it?. I don't know. I can imagine how to do, but sure there are better methods to do it, i recommend you read a lot of scientific paper, get the better document and do it.

    ReplyDelete
  41. Thank a million damiles

    ReplyDelete
  42. hi damiles,

    i've got the same problem as larun. I need to track vehicles and calculate their speed. I also read some scientific papers and got this solution to double difference the images first then use Camshift to track. i'll try it out. thank you so much for this. this is very helpful. :)

    ReplyDelete
  43. hi melissa,

    nice to meet you,our both project are little bit similar.
    actually what is double difference the image.i didn't get you properly beca just now i started my project.so,i don't know much in opencv
    could pls help me.

    GOOD LUCK

    Thanking You advance.
    Best Regards,
    larun

    ReplyDelete
  44. you should get a copy of Learning OpenCV by Gary Bradski and Adrian Kaehler. Double Differencing is like comparing 2 images in pixel level, the output is usually in binarized form, the white pixels are the difference between the two images. :) well, that's how i understood it.

    ReplyDelete
  45. Hi,i have a small doubt regarding loading images.

    myimage = cvLoadImage("a1.jpg",-1);

    instead of this can we load images by first asking th image name and then open the corresponding image.

    ReplyDelete
  46. Yes you can, you can do it with command line or anyway you think.

    ReplyDelete
  47. Thanks,withot using from command line,if suppose in the middle of a program i need to ask the user the name of image and get it substituted like the one program snippet which is not working.

    please tell me where i'm going wrong.



    IplImage *myimage;

    // load an image
    char imagename[20];
    cout<>imagename;

    myimage = cvLoadImage("imagename",1);

    ReplyDelete
  48. Thanks for the reply damiles.

    In the middle of program execution ,i need to ask the user to enter the image name and the display the image.please suggest the code snippet like that shown below which is not getting executed.



    IplImage *myimage;

    load an image
    string imagename;
    cout<<"enter the name of the image";
    getline(cin,imagename);

    myimage = cvLoadImage("imagename",1);

    ReplyDelete
  49. Excellent Man!
    I Appreciate.

    ReplyDelete
  50. Hai Damiles,

    I'm new in openCV, i've tried to capture from camera in windows and linux using logitech webcam.

    But now, i am trying to capture video from CCD camera (firewire input), what i get is only grayscale video.

    I'v e searched and some said it because CCD Camera with firewire input only be supported with OpenCV in 8bit. Other one said it needs directshow sdk, then what should i do?

    I've tried to convert each frame using cvCvtColor(frame, frameColor, CV_GRAY2BGR), but i couldn't works. Do you have any idea why??

    Thanks Before.

    ReplyDelete
  51. You are sure you get a frame with this camera? If you are under linux, you have to ensure the camera is working ok, check with xawtv for example. Then if xawtv works correctly then check you get a frame in opencv.

    ReplyDelete
  52. Thanks for your quick reply,

    how to check whether i get frame or not??
    That i sure is i can display the video and i can manipulate the video that i get from the camera, but the problem is i only get grayscale video. If i use my webcam i get perfect video with color video.

    i just searched and i get UYVY something which i don't understand.

    ReplyDelete
  53. have you tried to use directshow sdk along with opencv?

    i just wonder if i can capture the video using directshow and then manipulate the video using opencv..

    is it possible?

    ReplyDelete
  54. Hi, i no use win... and don't test with directshow, but yes, you can capture with any sdk and convert the frame to iplImage structure.

    ReplyDelete
  55. I don't need test with directshow because i no need it at this moment, but in future i will need use it.

    Directshow is not bad, is other way to capture images. As V4l or specific camera driver or similar...

    ReplyDelete
  56. How do u save all the frames in a single video and save them with the correct filename like "pic_0001", "pic_0002"??
    Thanks for your help. Really appreciate it.

    ReplyDelete
  57. Hi.
    What i'm trying to do is to try and save all the frame in a single avi video and save those frames in .jpg format with the correct filenameeg "depthmap0000.jpg", " depthmap0001.jpg" etc.

    Firstly, get the number of frames the avi video is holding.

    Secondly, loop over the number of frames one by one, then save these frames into the folder with the correct name accordingly to whichever frame they belong to.

    Can you like teach me cause i'm new to OpenCV.
    Thank you very much for your respond above. That was quick. *smile*

    ReplyDelete
  58. Thanks again for your help. Much appreciated

    ReplyDelete
  59. Hello,

    Good article but memory management is not shown. where are you releasing your memory? Give 5-10 mins and memory heap shall be full and not surprisingly program will crash!

    ReplyDelete
  60. I'm sorry Damiles,
    I didn't understeand the explanation you gave to lokye about saving each frame of a video in different images like out[fps].png, could you please be more specific, it would mean a lot to my graduation project, since i've got to learn openCV on my own! Thank you so much

    ReplyDelete
  61. It's very simple, but my english is too bad.

    If you want save all images/frames you capture with your cam, you only need save each image in the main loop you use to show the image:

    example:
    for(;;){
    IplImage* frame = 0;
    int c;

    frame = cvQueryFrame( capture );
    if( !frame )
    break;

    cvSaveImage("name_image.jpg", frame);
    ...

    ....

    ReplyDelete
  62. Hi Damiles,

    I really appreciate your tutorials. It really helps me a lot :D

    From this tutorial, I try to get the next frame and I really have no idea how to get it. Can you help me?

    Thanks a lot

    ReplyDelete
  63. inside a loop yo u must do cvQeuryFrame

    Regards.

    ReplyDelete
  64. Sorry for my poor explanation.

    Actually I mean the next frame of the current frame in the loop. In this tutorial, you calculate the difference between current frame and the previous one.

    I want to know how to calculate the difference between current frame and the next one.

    Hope you understand

    Thanks a lot

    ReplyDelete
  65. you never can get the future!
    You can't get next frame, if you get next frame then your actual frame is the past, no is actual ;) and next frame is the actual frame ;)

    ReplyDelete
  66. Yeah you're right.. haha how stupid I am - -"

    ReplyDelete
  67. it was great help.thanks.i appreciate it.

    ReplyDelete
  68. Hi I want your help to extract unique frames from video i.e. there should not be any duplicate Frame in the video if so discard it while saving the image.
    plz help me in this respect

    ReplyDelete
  69. What do you want to do exactly? you don't want save the image it's similar to other saved image? then you can do a basic math operation

    sum(Frame(t) - Frame(t-1)) < threshold

    then the image are same and you don't need save it. the sum function is you sum each pixel value.

    You can create your own function to solve your problem this function is a very simply and basic idea.

    Regards David.

    ReplyDelete
  70. hi !
    i debug, opencv error
    error C2065: 'colourImage' : undeclared identifier
    error C2065: 'difference' : undeclared identifier
    error C2065: 'temp' : undeclared identifier
    error C2065: 'movingAverage' : undeclared identifier
    error C2065: 'greyImage' : undeclared identifier
    Trying to fix this error , Any help is appreciated.
    thanks !

    ReplyDelete
  71. Hi,

    Can you give a tutorial of how to remove noise of a noisy image ???

    ReplyDelete
  72. Hi Damiles

    I am trying to extract frames from video file. I want to save each frame as image1.jpg, image2.jpg etc... but I couldn't able to save each frame. Only last or first frame only I able to save. How i'll resolve this problem. Pls help me to solve this issue.

    ReplyDelete
  73. i m new to opencv .. i need help regarding croping an image and saving it as other image.plz help me in this respect

    ReplyDelete
  74. thx a lot it helped me alot.keep up tha good work

    ReplyDelete
  75. maheshmhegade@gmail.comOctober 17, 2011 at 7:41 PM

    hi
    i m bit new to oppencv.i m doing some project i need to to store sequence of images in temporary memory and also want to retrieve them back according to need can anybody help me out ?please mail me at mahesshmhegade@gmail.com
    thank you

    ReplyDelete
  76. maheshmhegade@gmail.comOctober 17, 2011 at 7:42 PM

    sorry mail id is maheshmhegade@gmail.com

    ReplyDelete
  77. Hi, IplImage is a extension of CvArr then you can use as you do, the error is because you don't have initialized with image some of your images.

    ReplyDelete
  78. OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /home/sumit/Downloads/OpenCV-2.2.0/modules/core/src/matrix.cpp, line 641
    terminate called after throwing an instance of 'cv::Exception'
    what(): /home/sumit/Downloads/OpenCV-2.2.0/modules/core/src/matrix.cpp:641: error: (-5) Unknown array type in function cvarrToMat

    Aborted (core dumped)

    ReplyDelete
  79. This is what I receive when I run the above code,


    OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file /home/sumit/Downloads/OpenCV-2.2.0/modules/core/src/matrix.cpp, line 641
    terminate called after throwing an instance of 'cv::Exception'
    what(): /home/sumit/Downloads/OpenCV-2.2.0/modules/core/src/matrix.cpp:641: error: (-5) Unknown array type in function cvarrToMat

    Aborted (core dumped)

    ReplyDelete
  80. How to add back to original color of the image on yr results of cvAbsDiff, if u have performed your cvAbsDiff from using your converted grayscale images?

    ReplyDelete
  81. HI ..As a beginner in opencv, I find this site very useful...

    I have a doubt..
    I need to detect the frame which is same like the previous frames(may be 10 frames) ..Pls help me to proceed..

    ReplyDelete
  82. Hi, can i catch changing pixels from bit_image? I wanna draw rectangle changing pixels..

    ReplyDelete
  83. Hi, I am after getting your code working successfully. I was wondering though, say I wanted to get the diff not from the previous frame, but from the fifth last frame, do you know how I might go about doing it?

    Thanks!

    ReplyDelete
  84. hello,
    how to isolate an image from capturing video stream?
    Please reply...thank you..

    ReplyDelete
  85. Hello,

    This might be a bit off topic.
    I have a logitech webcam and it shows from the v4l2 that the camera retrieves frames in YUYV format. However, Opencv requires all pixels to be in RGB format so it converts each frame into rgb in the cap_libv4l file in highgui. I tried to change V4L2_PIX_FMT_BGR24 to V4L2_PIX_FMT_YUYV and then make and install opencv again but when i run the code it does nothing but changing the size of the image and prints an error "libv4l unable to ioctl S_FMT" and everything else works fine.

    Can you help me retrieve images in YUYV format??

    Thank you!

    ReplyDelete
  86. hello sir,
    I want to detect eye blink in my project. I want to detect close and open eye and apply mouse click function accordingly. How can i do this? Could you please explain me??:)

    ReplyDelete
  87. hi, im trying to do image conversion using opencv2.1
    so i got the input frame using logitech camera with this function
    int main()
    {
    CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
    if ( !capture )
    {
    fprintf( stderr, "ERROR: capture is NULL \n" );
    getchar();
    return -1;
    }
    // Create a window in which the captured images will be presented
    cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );

    while ( 1 )
    {
    // Get one frame
    IplImage* frame = cvQueryFrame( capture );
    if ( !frame )
    {
    fprintf( stderr, "ERROR: frame is null...\n" );
    getchar();
    break;
    }
    cvShowImage( "mywindow", frame );


    and i want to display the frame output of conversion of gausian blurr with this function
    while ( 1 )
    {
    // Get one frame
    IplImage* out = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 3 );
    cvSmooth( frame, out, CV_GAUSSIAN, 11, 11 );


    if ( !out )
    {
    fprintf( stderr, "ERROR: frame is null...\n" );
    getchar();
    break;
    }

    cvShowImage( "output" , out);

    i got the 2 window, 1 is input frame, 1 is output frame.
    but the image is freeze, i dont know what should i do. Plss help me
    im guessing the problem is cvGetSize

    ReplyDelete
  88. thanks for tutorial. could you update link of code, please. cannot download it.

    ReplyDelete
  89. Hola damiles que tal,

    im starting with opencv, and i was wondering if you could recommend me some cameras, to start in the computer vision, not something professional, more like proyects at the university and practice.

    regards

    ReplyDelete
  90. So now you can listen to any music from any where non-stop and cost free.

    Helix Server Basic Free streaming media server software which can distribute live and on-demand video and other media.
    These attributes, such as instrumentation, vocals, lyrics, harmony and almost 400 others allow songs with similar attributes to
    be related to each other and played together in
    a pleasant music mix.

    ReplyDelete
  91. The weapons, enviroments, and vehicles better retail outlet impressive..... Aliens should be sensible and scary........ characters fit the profiles of the game characters............ it better look and feel like halo.

    ReplyDelete
  92. Wow! Ater all I got a website from where I be able
    to truly take helpful information concerning
    my study and knowledge.

    ReplyDelete
  93. This splits each woman in to 8 sorts and offers information
    on eeach of them individually. Maybe I will be too ideal,
    or too accomplished, or ttoo boring i always don't think We're.
    Real understanding of women gives you a distinct advantage over guys have no clue.

    ReplyDelete
  94. Voսs écrivez coոtinuellement des posts intéressants

    ReplyDelete
  95. Je vais finir de jeter un coup d'oeil à tout cela dans
    la semaine

    ReplyDelete
  96. Thank you for the auspicious writeup. It in reality was a leisure
    account it. Look complicated to more delivered agreeable from you!
    By the way, how could we keep in touch?

    ReplyDelete
  97. Howdy! Would you mind if Ishre your blog with my twitter group?
    There's a lot of people that I think would really enjoy
    your content. Please let me know. Thanks

    ReplyDelete