728x90
728x90
python code
import cv2
# open webcam
cam = cv2.VideoCapture(0)
# get fps
fps = cam.get(cv2.CAP_PROP_FPS)
if cam.isOpened() is False:
print('error')
while True:
#get frame
ret, frame = cam.read()
if ret is not True:
break
if frame is None:
break
cv2.imshow('a', frame)
if (cv2.waitKey(1) & 0xFF) == 27:
break
c++ code
#include <opencv2/opencv.hpp>
void main()
{
cv::VideoCapture cap(0);
if (!cap.isOpened())
{
std::cout << "Cannot open the video file" << std::endl;
return -1;
}
while(true)
{
cv::Mat frame;
bool ret = cap.read(frame);
if(ret == false)
break;
cv::imshow("image", frameA);
if(cv::waitKey(25) >= 0)
break;
}
}
728x90
반응형
'Development > OpenCV' 카테고리의 다른 글
libSM.so.6: cannot open shared object file (0) | 2023.04.19 |
---|---|
Could not load the Qt platform plugin xcb (0) | 2023.02.10 |
[OpenCV] libgthread-2.0.so.0: cannot open shared object file 해결 (0) | 2022.01.14 |
[OpenCV] OpenCV circle, rectangle, text 그리기와 PIL 한글 text (1) | 2021.11.17 |
[OpenCV] libGL.so.1: cannot open shared object file 해결 (0) | 2021.10.25 |
댓글