Scaled-YOLOv4-TensorRT icon indicating copy to clipboard operation
Scaled-YOLOv4-TensorRT copied to clipboard

How can I use a webcam in this object?

Open TweepingH opened this issue 3 years ago • 2 comments

I wanna use a webcam to detect(real-time) what can I do?

TweepingH avatar May 19 '21 09:05 TweepingH

Use OpenCV

https://answers.opencv.org/question/1/how-can-i-get-frames-from-my-webcam/

Here is the accepted answer, which you can work into the code:

#include "opencv2/opencv.hpp"
using namespace cv;
int main(int argc, char** argv)
{
    VideoCapture cap;
    // open the default camera, use something different from 0 otherwise;
    // Check VideoCapture documentation.
    if(!cap.open(0))
        return 0;
    for(;;)
    {
          Mat frame;
          cap >> frame;
          if( frame.empty() ) break; // end of video stream
          imshow("this is you, smile! :)", frame);
          if( waitKey(10) == 27 ) break; // stop capturing by pressing ESC 
    }
    // the camera will be closed automatically upon exit
    // cap.close();
    return 0;
}

casper-hansen avatar May 19 '21 12:05 casper-hansen

@casperbh96 thank you! although I have solved it, your answer still valuable to me

TweepingH avatar May 20 '21 00:05 TweepingH