View Single Post
  #2   Spotlight this post!  
Unread 21-02-2016, 18:46
Noviv's Avatar
Noviv Noviv is offline
Registered User
FRC #1477 (Texas Torque)
Team Role: Programmer
 
Join Date: Jun 2015
Rookie Year: 2013
Location: Texas
Posts: 5
Noviv is an unknown quantity at this point
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.
Reply With Quote