- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am working on pedestrian demo code. It accepts a video file as input. How can I modify it open the webcam and start using it?
std::unique_ptr<ImageReader> video = ImageReader::CreateImageReaderForPath(video_path);
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I have been able to modify the code to accept the live camera feed as input instead of a video file. I basically modified below lines:
// Opening video //std::unique_ptr<ImageReader> video = ImageReader::CreateImageReaderForPath(video_path); //cv::Mat video = cv::imread("cam", cv::IMREAD_COLOR); //cv::VideoCapture cap(1); //PT_CHECK(video->IsOpened()) << "failed to open video: " << video_path; //double video_fps = video->GetFrameRate(); double video_fps = 29.5634; //if (first_frame > 0) video->SetFrameIndex(first_frame); //if (should_show) //{ //std::cout << "To close the application, press 'CTRL+C' or any key with focus on the output window" << std::endl; //} int frame_idx = 0; for (;;) { //auto pair = video->Read(); //cv::Mat frame = pair.first; //int frame_idx = pair.second; cv::VideoCapture cap; cap.open(0); cv::Mat frame; cap.read(frame); if (frame.empty()) break; frame_idx = frame_idx + 1; /* PT_CHECK(frame_idx >= first_frame); if ((last_frame >= 0) && (frame_idx > last_frame)) { std::cout << "Frame " << frame_idx << " is greater than last_frame = " << last_frame << " -- break"; break; }*/
This build successfully with no errors. When I run the project, I was able to open the camera but terminal kept on showing below error:
InferenceEngine:
API version ............ 1.6
Build .................. 23224
Loading plugin CPU
API version ............ 1.6
Build .................. 23224
Description ....... MKLDNNPlugin
[ WARN:0] terminating async callback
[ WARN:0] terminating async callback
[ WARN:0] terminating async callback
[ WARN:0] terminating async callback
[ WARN:0] terminating async callback
[ WARN:0] terminating async callback
[ WARN:0] terminating async callback
Also the webcam was also turning on and then going off continuously. What does this means and how can I resolve this issue.? Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear R, A,
Why not study the smart classroom demo which uses webcam by default ?
The smart classroom demo uses ImageGrabber to accomplish what you want. video_path is determined from the -i passed in by the user, which ultimately gets stored in FLAGS_i.
log::info << "Reading video '" << video_path << "'" << slog::endl; ImageGrabber cap(video_path); if (!cap.IsOpened()) { slog::err << "Cannot open the video" << slog::endl; return 1; }
Hope it helps. Thanks for using OpenVino !
Shubha

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page