Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use a webcam in this object? #18

Open
TweepingH opened this issue May 19, 2021 · 2 comments
Open

How can I use a webcam in this object? #18

TweepingH opened this issue May 19, 2021 · 2 comments

Comments

@TweepingH
Copy link

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

@casper-hansen
Copy link

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;
}

@TweepingH
Copy link
Author

TweepingH commented May 20, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants