网络编程
位置:首页>> 网络编程>> Python编程>> jupyter notebook oepncv 显示一张图像的实现

jupyter notebook oepncv 显示一张图像的实现

作者:农民小飞侠  发布时间:2022-03-26 20:09:19 

标签:jupyter,notebook,oepncv,图像

感想

我们在用jupyter notebook的时候,经常需要可视化一些东西,尤其是一些图像,我这里给个sample code

环境

opencv-python
matplotlib
numpy

sample


import os
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
img_dir='/Users/eric/Documents/data/wheel_train_val/train/non_defect/'
filename='00005.BMP_block_8.jpg'
img = cv2.imread(img_dir +os.sep+ filename)
plt.imshow(img)
plt.show()

补充知识:jupyter notebook 调用摄像投运行程序

import cv2 ----前提是需要安装opencv 可以百度下如何安装即可


cap = cv2.VideoCapture(0)
while(1):
 # get a frame
 ret,frame = cap.read()
 # show a frame
 cv2.imshow("capture", frame)
 if cv2.waitKey(1) & 0xFF == ord('q'):
   cv2.imwrite("./test.jpeg", frame)
   break
cap.release()
cv2.destroyAllWindows()

上述在jupyter notebook 中运行如下

jupyter notebook oepncv 显示一张图像的实现

来源:https://blog.csdn.net/w5688414/article/details/83660223

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com