站点图标 AI技术聚合

Go1 头部相机传图到自己电脑上进行开发—环境配置相关

Go1 头部相机传图到自己电脑上进行开发—环境配置Trick

0 头部相机发送

Go 1头部相机发送可以参考宇树B站的camera_sdk教程。
本文主要解决在自己电脑上接收图像camera_sdk会遇到报错等各种问题,但是在实际使用中,我们有时候其实只需要一个RGB图就可。电脑与Go1用网线先链接。

1 更换软件源

首先在/etc/apt/sources.listsudo apt-get update添加清华源

2 安装基础的编译环境

sudo apt-get install build-essential cmake unzip pkg-config libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev libjpeg-dev libpng-dev libtiff-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk-3-dev libopenblas-dev libatlas-base-dev liblapack-dev gfortran libhdf5-serial-dev python3-dev python3-tk python-imaging-tk

3 安装GStreamer

sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio

4 安装CMake-gui

sudo apt-get install cmake-gui

5 opencv + contrib 4.1.1

5.1 安装VTK-7.1.1

下载VTK-7.1.1:https://vtk.org/download/

然后是:

mkdir build 
cd build
cmake ..
sudo make -j7
sudo make install 

如果VTK不能顺利装成功,用release模式编译就可以解决这个东西。

5.2 opencv 4.1.1+ contrib 4.1.1

opencv下载链接:https://github.com/opencv/opencv/releases?page=2

opencv_contrib下载链接:https://github.com/opencv/opencv_contrib/tags?after=3.4.8

编译完成opencv+contrib模块,记得勾选GStreamer!!!!

6 Python实现图传(C++同理)

import  cv2

cam =  1    # 前方
# cam = 2 # 下巴
udpstrPrevData = "udpsrc address=192.168.123.123"+ " port=" # 前面的IP需要替换为自己的IP,ifconfig可以看自己的IP
udpPORT = [9201, 9202, 9203, 9204, 9205]
udpstrBehindData = " ! application/x-rtp,media=video,encoding-name=H264 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! appsink"# 官方是ARM64架构的解码器,此处需要改成x86架构下的解码器
udpSendIntegratedPipe = udpstrPrevData +  str(udpPORT[cam-1]) + udpstrBehindData
print("{}/n".format(udpSendIntegratedPipe))
cam =  cv2.VideoCapture(udpSendIntegratedPipe)
while(True):
    ret, image = cam.read()
    # print(ret)
    image  = cv2.flip(image, -1)
    cv2.imshow("image" , image)
    if cv2.waitKey(1) & 0xFF == ord('q'):  # 读完按 q 退出
        break

文章出处登录后可见!

已经登录?立即刷新
退出移动版