Using opencv to process the video stream from camera
来源:互联网 发布:电脑屏幕录制软件 免费 编辑:程序博客网 时间:2024/06/05 21:04
Here, we just talk about how to obtain the video stream from opencv and then to process the video stream to get new video stream.
1st, obtain the video stream from the camera.
2nd, process each frame, draw one circle, one rectangle on the frame.
Here is the code.
#include<iostream>#include<stdio.h>#include<opencv/highgui.h>#include<opencv2/opencv.hpp>using namespace std;using namespace cv;const int X = 640,Y = 480; // the size of the framevoid MyEllipse(Mat img ,double angle); // draw ellipsevoid MyRectangle(Mat img, Point a, Point b); // draw rectanglevoid MyCircle(Mat img, Point center); // draw circleint main(int argc,char* argv[]){VideoCapture cap(0); // open the camerachar name[]="camera";if(!cap.isOpened()){cout << "error 1" << endl;return -1;}namedWindow(name, WINDOW_AUTOSIZE); // generate a window to show imagemoveWindow(name,200,200); // move from top left cornet to position of (200,200)while(1){ // process the image in a loopMat frame;bool bSuccess = cap.read(frame); // obtain each frame from cameraif(!bSuccess){cout << "can not read a frame from video stream" << endl;break;}MyCircle(frame,Point(X/2,Y/2)); // draw a circleMyRectangle(frame, Point(225,450), Point(415,480)); // draw a rectangleimshow(name, frame); // show the frameif(waitKey(30)==27){ cout << "finished" << endl; break;}}return 0;}void MyRectangle(Mat img, Point a, Point b){ // the function to draw a rectangle int thickness = CV_FILLED;int lineType = 8;rectangle(img, a, b, Scalar(255,0,0), thickness, lineType);}void MyCircle(Mat img, Point center){ // the function to drwa a circle int radius = 20; int lineType = 8; circle(img, center, radius, Scalar(0,0,255),CV_FILLED,lineType);}/*void MyEllipse(Mat img,double angle){ // the function to draw an ellipseint thickness = 2;int lineType = 8;ellipse(img, Point(X/2.0,Y/2.0), Size(X/4.0, Y/16.0),angle, 0, 360, Scalar(255,0, 0), thickness, lineType);}*/ //cout << frame.rows << " * " << frame.cols << endl; /*MyEllipse(frame, 0);MyEllipse(frame, 90);MyEllipse(frame, 45);MyEllipse(frame, -45); */
0 0
- Using opencv to process the video stream from camera
- ios学习--How to capture video frames from the camera as images using AV Foundation
- How to capture video frames from the camera as images using AV Foundation
- How to capture video frames from the camera as images using AV Foundation on iOS
- Learning OpenCV: read video from Camera
- python opencv cv2 to process video
- How to download streaming audio or video media from the internet using the MMS protocol?
- Open the Android native Camera using OpenCV
- OpenCV video process
- Capture video from USB by using OpenCV videoInput
- from c to c++: using the boolean
- Two ways to access camera using opencv library
- the limit to the amount of thread from a process
- The MPEG Video Standards – from 1 to 21
- How to know the port which process is using
- media foundation (Using the Source Reader to Process Media Data)
- Java How to get the PID from a process?
- capture from the camera
- 使用commons-email-1.3.2.jar包发送邮件
- 经典排序算法 – 插入排序Insertion sort
- Python根据数量生成正确顺序的ip地址
- 打造一个精简的BaseActivity
- Android应用的调试
- Using opencv to process the video stream from camera
- oracle 如何给新加字段赋默认值
- poj1273 网络流 Edmonds_Karp
- JavaScript之apply,call以及bind方法
- Core Animation - 过渡动画 CATransition
- linux下调试PHP core文件
- 调用系统相机 bundle为null
- 得分(Sorce,ACM/ICPC Seoul 2005,Uva1585)
- Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLIC