pycharm可以调用openmv的摄像头吗
-
pycharm可以调用openmv的摄像头吗,想在pycharm中显示openmv摄像头所展示的图像
-
不能,只能使用OpenMV IDE开发。
-
请问您有解决这个问题吗
-
import serial
import cv2
import numpy as npser = serial.Serial('COM3', 115200, timeout=1) # 替换为你的端口
while True:
try:
hex_data = ser.readline().decode().strip()
if hex_data:
img_bytes = bytes.fromhex(hex_data)
nparr = np.frombuffer(img_bytes, np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
cv2.imshow("OpenMV Image", img)
if cv2.waitKey(1) & 0xFF == 27: # 按 ESC 退出
break
except KeyboardInterrupt:
breakser.close()
cv2.destroyAllWindows()
此代码放在pycharm
-
import sensor, time, pyb, ubinascii
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)while True:
img = sensor.snapshot().compress(quality=70) # 压缩质量为70%
hex_data = ubinascii.hexlify(img).decode() # 转为十六进制字符串
print(hex_data) # 发送数据
pyb.delay(1000)
此代码放在openmv ide烧录