PYNQ(一)镜像烧录,上手测试USB摄像头及显示

重新烧录镜像

格式化SD卡

烧录PYNQ镜像前要对SD卡进行格式化,一般使用SDFormatter(树莓派也使用这个软件格式化)
在这里插入图片描述

烧录镜像

镜像烧录用Win32DiskImager,我使用的是V2.4版本在这里插入图片描述

Putty连接开发板

使用该软件的目的是查看Ubuntu、python版本,实质上就是一个linux系统,可以更新系统,安装Keras/Tensorflow 等库文件,和在虚拟机下的操作相差无几,需要注意的是putty下串口波特率要设为112500,不是和设备管理器中的波特率一致。
在这里插入图片描述

查看ubuntu版本
cat  /etc/issue

在这里插入图片描述
Putty应该还可以查看PYNQ的运行信息等,之前没用过
在这里插入图片描述

jupyter测试摄像头&显示器

在/base/vedio下新建USB_camera_hdmi.ipynb
在这里插入图片描述
代码引用这篇博客的源代码
链接: link.

// code
from pynq.overlays.base import BaseOverlay
from pynq.lib.video import *
import cv2
import numpy as np
import time
 
base = BaseOverlay("base.bit")
 
# monitor configuration: 640*480 @ 60Hz,在此我们设置HDMI输出为640*480
Mode = VideoMode(640,480,24)
hdmi_out = base.video.hdmi_out
hdmi_out.configure(Mode,PIXEL_BGR)
hdmi_out.start()
 
# camera (input) configuration
frame_in_w = 640
frame_in_h = 480
 
 
videoIn = cv2.VideoCapture(0)
videoIn.set(cv2.CAP_PROP_FRAME_WIDTH, frame_in_w);
videoIn.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_in_h);
print("capture device is open: " + str(videoIn.isOpened()))
 
 
num_frames = 1000
readError = 0
 
globalimage=np.zeros((640,480,3), np.uint8) 
 
while True:   
    # read next image
    start = time.time()
    ret, frame_vga = videoIn.read()
    globalimage=frame_vga
 
    if (ret):
        outframe = hdmi_out.newframe()
        outframe[:] = frame_vga
        hdmi_out.writeframe(outframe)
        #print("test ok")
    else:
        readError += 1
    end = time.time()
    seconds=end-start
    num_frames -=1
    if num_frames<10:
        break

  • 2
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值