Skip to Content
Hands-On Robotics Programming with C++
book

Hands-On Robotics Programming with C++

by Dinesh Tavasalkar
March 2019
Intermediate to advanced
312 pages
7h 37m
English
Packt Publishing
Content preview from Hands-On Robotics Programming with C++

The OpenCV camera feed program

We will now write a simple C++ program to view the camera feed from the Pi camera. The program for viewing the video is as follows. The program is named Camerafeed.cpp and you can download it from the Chaper07 folder of the GitHub repository:

int main(){ Mat videoframe; VideoCapture vid(0); if (!vid.isOpened()) {cout<<"Error opening camera"<<endl; return -1; } for(;;) { vid.read(videoframe); imshow("Frame", videoframe); if (waitKey(1) > 0) break; } return 0;}

The OpenCV libraries and namespace declaration is similar to that of the previous program:

  1. First, inside the main function, we are declaring a matrix variable called videoframe.
  2. Next, the VideoCapture datatype is used to capture a video feed from the Pi ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Robotics Programming

Learn Robotics Programming

Danny Staple
C++ Reactive Programming

C++ Reactive Programming

Praseed Pai, Peter Abraham

Publisher Resources

ISBN: 9781789139006Supplemental Content