Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. taking a video from usb cam

taking a video from usb cam

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asmaa Khaled FCI
    wrote on last edited by
    #1

    Hi, It is a code for a robot i want code take vedio from usb cam and make it frams(pics) as i could use it later @ another code the code is in C++ i found one but there is a compiler error it is little but i canot fixed it

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

    IplImage* src = NULL;

    int _tmain(int argc, _TCHAR* argv[])
    {

    int key;
    CvCapture* capture = NULL;

    if(NULL==(capture = cvCaptureFromCAM(-1)))
    {
    printf("\nError on cvCaptureFromCAM");
    return -1;
    }

    //-----
    cvNamedWindow("Capture", CV_WINDOW_AUTOSIZE);
    cvNamedWindow("Capture2", CV_WINDOW_AUTOSIZE);

    cvMoveWindow("Capture", 50, 50);
    cvMoveWindow("Capture2", 320, 50);

    for(;;){

    if(NULL==(src=cvQueryFrame(capture))){
      printf("\\nError on cvQueryFrame");
      break;
    }
    
    
    cvShowImage("Capture", src);
    
    
    key = cvWaitKey(10);
    
    if(key==0x1b)
      break;
    

    }

    cvReleaseCapture(&capture);
    cvDestroyWindow("Capture");

    return 0;

    }

    L T _ 3 Replies Last reply
    0
    • A Asmaa Khaled FCI

      Hi, It is a code for a robot i want code take vedio from usb cam and make it frams(pics) as i could use it later @ another code the code is in C++ i found one but there is a compiler error it is little but i canot fixed it

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

      IplImage* src = NULL;

      int _tmain(int argc, _TCHAR* argv[])
      {

      int key;
      CvCapture* capture = NULL;

      if(NULL==(capture = cvCaptureFromCAM(-1)))
      {
      printf("\nError on cvCaptureFromCAM");
      return -1;
      }

      //-----
      cvNamedWindow("Capture", CV_WINDOW_AUTOSIZE);
      cvNamedWindow("Capture2", CV_WINDOW_AUTOSIZE);

      cvMoveWindow("Capture", 50, 50);
      cvMoveWindow("Capture2", 320, 50);

      for(;;){

      if(NULL==(src=cvQueryFrame(capture))){
        printf("\\nError on cvQueryFrame");
        break;
      }
      
      
      cvShowImage("Capture", src);
      
      
      key = cvWaitKey(10);
      
      if(key==0x1b)
        break;
      

      }

      cvReleaseCapture(&capture);
      cvDestroyWindow("Capture");

      return 0;

      }

      L Offline
      L Offline
      loyal ginger
      wrote on last edited by
      #2

      It's hard to tell what the problem is. Where are the "cv.h" and "highgui.h" files? Can you post the complete error message here?

      L 1 Reply Last reply
      0
      • A Asmaa Khaled FCI

        Hi, It is a code for a robot i want code take vedio from usb cam and make it frams(pics) as i could use it later @ another code the code is in C++ i found one but there is a compiler error it is little but i canot fixed it

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

        IplImage* src = NULL;

        int _tmain(int argc, _TCHAR* argv[])
        {

        int key;
        CvCapture* capture = NULL;

        if(NULL==(capture = cvCaptureFromCAM(-1)))
        {
        printf("\nError on cvCaptureFromCAM");
        return -1;
        }

        //-----
        cvNamedWindow("Capture", CV_WINDOW_AUTOSIZE);
        cvNamedWindow("Capture2", CV_WINDOW_AUTOSIZE);

        cvMoveWindow("Capture", 50, 50);
        cvMoveWindow("Capture2", 320, 50);

        for(;;){

        if(NULL==(src=cvQueryFrame(capture))){
          printf("\\nError on cvQueryFrame");
          break;
        }
        
        
        cvShowImage("Capture", src);
        
        
        key = cvWaitKey(10);
        
        if(key==0x1b)
          break;
        

        }

        cvReleaseCapture(&capture);
        cvDestroyWindow("Capture");

        return 0;

        }

        T Offline
        T Offline
        Tim Craig
        wrote on last edited by
        #3

        What is the compiler error? No one is going to type in your code and try to compile it.

        You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.

        1 Reply Last reply
        0
        • L loyal ginger

          It's hard to tell what the problem is. Where are the "cv.h" and "highgui.h" files? Can you post the complete error message here?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          highgui.h and cv.h are headers from the openCV[^] library. Asmaa, if there is a compile error you will need to tell us what it is. We aren't psychic.

          1 Reply Last reply
          0
          • A Asmaa Khaled FCI

            Hi, It is a code for a robot i want code take vedio from usb cam and make it frams(pics) as i could use it later @ another code the code is in C++ i found one but there is a compiler error it is little but i canot fixed it

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

            IplImage* src = NULL;

            int _tmain(int argc, _TCHAR* argv[])
            {

            int key;
            CvCapture* capture = NULL;

            if(NULL==(capture = cvCaptureFromCAM(-1)))
            {
            printf("\nError on cvCaptureFromCAM");
            return -1;
            }

            //-----
            cvNamedWindow("Capture", CV_WINDOW_AUTOSIZE);
            cvNamedWindow("Capture2", CV_WINDOW_AUTOSIZE);

            cvMoveWindow("Capture", 50, 50);
            cvMoveWindow("Capture2", 320, 50);

            for(;;){

            if(NULL==(src=cvQueryFrame(capture))){
              printf("\\nError on cvQueryFrame");
              break;
            }
            
            
            cvShowImage("Capture", src);
            
            
            key = cvWaitKey(10);
            
            if(key==0x1b)
              break;
            

            }

            cvReleaseCapture(&capture);
            cvDestroyWindow("Capture");

            return 0;

            }

            _ Offline
            _ Offline
            __erfan__
            wrote on last edited by
            #5

            do you have opencv installed on your system?

            if(no){install opencv;}

            add opencv include and source directories to your compiler setting and at the end add the libraries in your project setting

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups