-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1_Numpy.py
More file actions
31 lines (26 loc) · 731 Bytes
/
1_Numpy.py
File metadata and controls
31 lines (26 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2 as cv
import numpy as np #Python科学技术np包
#Numpy数组操作
def video_demo():
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(image):
print(type(image))
print(image.size)
print(image.shape)
print(image.dtype)
print(np.array(image)) # 矩阵数组
src = cv.imread("C:/1/1.jpg")
cv.namedWindow('input_image', cv.WINDOW_AUTOSIZE)
cv.imshow('input_image', src)
get_image_info(src)
gray = cv.cvtColor(src,cv.COLOR_BGR2GRAY)
cv.imwrite("C:/1/111.jpg",gray)
cv.waitKey(0)
cv.destroyAllWindows()