opencv-python
代码如下:
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
#Define the codec and create VideoWrite object, 10 is fps, (640,480) is screen size
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('./video/cameravideo/cameraoutput.avi', fourcc, 10, (640,480))
while(1):
#get a frame
ret, frame = cap.read()
#save a frame
out.write(frame)
#show a frame
cv2.imshow("capture", frame)
#press 'q' to quit
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
out.release()
cv2.destroyAllWindows()
opencv c++ 代码:
#include <iostream>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#incl