opencv3.0第一天讀取攝像頭和圖片大小型別
阿新 • • 發佈:2018-11-03
import cv2 as cv import numpy as np def video_demo(): ##呼叫攝像頭 capture = cv.VideoCapture(0) while(True): capture = cv.VideoCapture(0) while (True): ret, frame = capture.read() frame = cv.flip(frame, 1) cv.imshow("video", frame) c = cv.waitKey(50) if c == 27: break def get_image_info(contours): ##讀取圖片大小 print(type(contours)) print(contours.shape) print(contours.size) print(contours.dtype) pixel_data = np.array(contours) print(pixel_data) print("--------- Python OpenCV Tutorial ---------") src = cv.imread("C:/Users/weiqiangwen/Desktop/sest/contours.png") cv.namedWindow("input contours",cv.WINDOW_AUTOSIZE) cv.imshow("contours", src) cv.imwrite("C:/Users/weiqiangwen/Desktop/sest/baocun/contours.png", src) get_image_info(src) video_demo() cv.waitKey(0) cv.destroyAllWindows()