龙空技术网

OPENCV-python 第一天

土的掉渣的工程博士 187

前言:

而今你们对“opencvforpython35”大约比较讲究,兄弟们都想要知道一些“opencvforpython35”的相关知识。那么小编在网摘上汇集了一些有关“opencvforpython35””的相关内容,希望看官们能喜欢,朋友们一起来学习一下吧!

Jupyter notebook

# To add a new cell, type '# %%'# To add a new markdown cell, type '# %% [markdown]'# %%from IPython import get_ipython# %%import numpy as npprint(np.zeros([2,3]))# %%import cv2print(cv2.__version__)# %%#opencv 设有opencv-python 和opencv-contrib-python#opencv-python opencv-contrib-python pytesseract# pip install  opencv-python=3.4.20.35 opencv-contrib-python=3.4.20.35 pytesseract#上述已经给了# %%import cv2 as cvimport numpy as np import matplotlib.pyplot as pltget_ipython().run_line_magic('matplotlib', 'inline')# %%img = cv.imread('./images/car.png')cv.namedWindow('CAR',cv.WINDOW_AUTOSIZE)cv.imshow('CAR',img)cv.waitKey(0)cv.destroyAllWindows()# %%img.shape# %%img.dtype# %%type(img)# %%img2= img.reshape(1650,949,1)cv.imshow('new',img2)cv.waitKey(0)cv.destroyAllWindows()# %%img# %%#显示图像信息def showImg(name,img):    cv.imshow(name,img)    cv.waitKey(0)    cv.destroyAllWindows()# %%h,w,c= img.shape# %%np.zeros((3,4),np.uint8)# %%np.array(    [        [[1,2],[3,4]],        [[1,3],[2,4]],        [[4,2],[3,1]]    ])# %%for row in range(h):    for col in range(w):        for ch in range(c):            img[row,col,ch]=100img[:,:,1]=255showImg('new',img)# %%gray_img = cv.imread('./images/lena.jpg',cv.IMREAD_GRAYSCALE)showImg('gray_imag',gray_img)# %%gray_img.shape# %%#读取视频videos = cv.VideoCapture('./images/test.mp4')if videos.isOpened():    ret,frame = videos.read()else:    ret =False   # %%while ret:    ret,fram = videos.read()    if frame is  None:        break    if ret==True:        gray = cv.cvtColor(fram,cv.COLOR_BGR2GRAY)        cv.imshow('gray',gray)        k=cv.waitKey(50)        if k&0xff==27:            breakvideos.release()cv.destroyAllWindows()# %%# ROI  截取图片cat = cv.imread("./images/cat.jpg")cv.imshow('cat',cat)cat_block = cat[0:200,0:250]showImg('cat_block',cat_block)cv.waitKey(0)cv.destroyAllWindows()# %%#获取通道数b,g,r = cv.split(cat)# %%b #每一行的中每个点的B通道像素# %%cat# %%

标签: #opencvforpython35