Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   General Forum (http://www.chiefdelphi.com/forums/forumdisplay.php?f=16)
-   -   trying to use usb webcam with opencv (http://www.chiefdelphi.com/forums/showthread.php?t=144358)

Bernstern 21-02-2016 16:20

trying to use usb webcam with opencv
 
Hello,

My team has been trying to use the Tower tracker program to little avail, but our hardest challenge is using our Microsoft webcam as the vision input. I checked out mjpeg streamer but couldn't understand it and have gotten no where with it. Any help would be greatly appreciated/

Noviv 21-02-2016 18:46

Re: trying to use usb webcam with opencv
 
My team isn't using the Tower Tracker program, so I can't help you with that, sorry.

But, if you are using OpenCV in C/C++, all you should have to do is declare a new VideoCapture and use the Mat that you get from the device. You can then play around with the Mat using OpenCV functions (just google what you want to do).

Code:

#include "opencv2/opencv.hpp"

int main() {
    VideoCapture cap(0);
    Mat frame;

    namedWindow("Webcam");

    while (true) {
        cap >> frame;

        //opencv functions go here

        imshow("Webcam", frame);
        if (waitKey(30) >= 0) {
            break;
        }
    }

    cap.release();
}

If you have another webcam on the computer/device you are running this program on, just increase 0 to 1, 2, etc until you get the right device.


All times are GMT -5. The time now is 02:05.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi