You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Software_Architecture/mediamodule/examples/example_putImagetrans.cc

119 lines
4.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* @file example_getRectFrame.cc
* @brief This file is part of UnitreeCameraSDK.
* @details This example that how to Transmission picture
* @author SunMingzhe
* @date 2021.12.07
* @version 1.1.0
* @copyright Copyright (c) 2020-2021, Hangzhou Yushu Technology Stock CO.LTD. All Rights Reserved.
*/
#include <UnitreeCameraSDK.hpp>
#include <unistd.h>
/*
发送端:
方法概述采用udp方法输出图片传输方式已写入程序由StereoCameraCommon::startCapture(true,false)中第一个参数控制定向udp传输当其为true时打开udp264硬编码传输模式
参数配置文件中IpLastSegment是接收端ip接收端地址必须是192.168.123.IpLastSegment。
配置文件中Transmode决定传输模式
配置文件中Transrate决定传输速率限制了传输速率小于图片速率
端口9201~9205分别对应前方下巴腹部
启动自定义图传时需使用kill.sh文件关闭Unitree/autostart/02camerarosnode程序来解除相机占用Unitree/autostart/04imageai来释放算力。
(也可使用以下几条指令
ps -A | grep point | awk '{print $1}' | xargs kill -9
ps -aux|grep mqttControlNode|grep -v grep|head -n 1|awk '{print $2}'|xargs kill -9
ps -aux|grep live_human_pose|grep -v grep|head -n 1|awk '{print $2}'|xargs kill -9
传输图片模式由配置文件中Transmode决定该值只可通过读取配置文件方式写入
0传输左目原始图片
1传输双目原始图片
2传输左目畸变校正后图片视野范围角度可调60~140
3传输双目畸变校正后图片
※※※注意,双目图的最后的左右目输出位置是反的。左目->右图,右目->左图
4不建议使用Depthmode = 2时 可输出深度图和对应左目图片,不建议使用。
*/
/*
sender:
Introduction: This program uses directed UDP methods to output pictures, transfer method written in programs. StereoCameraCommon::startCapture(true,false) the first parameter is a switch.
parameter:IpLastSegment is listener ip. listener ip:192.168.123.IpLastSegment
Transrate(config yaml) Transmission rate.it must lower than FrameRate
port:9201~9205 -> Front,chin,left,right,abdomen
If you start this file, you must bash "kill.sh" to turn off automatic startup program. "Unitree/autostart/02camerarosnode/kill.sh" and "Unitree/autostart/04imageai/kill.sh".
You can also use the following instructions:
ps -A | grep point | awk '{print $1}' | xargs kill -9
ps -aux|grep mqttControlNode|grep -v grep|head -n 1|awk '{print $2}'|xargs kill -9
ps -aux|grep live_human_pose|grep -v grep|head -n 1|awk '{print $2}'|xargs kill -9
Transfer picture mode: Decided by Transmode in the configuration yaml, which only writes in programs by reading the configuration yaml.
0ori left
1ori stereo
2rect left
3rect stereo
※※※warning:The last left and right output position of the stereo picture is reversed left cam-> right picture right cam -> left picture
4Not recommended for use!!set Depthmode = 2 , rect left && depthimage
*/
/*
local ip config
ip 192.168.123.x
netmask 255.255.255.0
gateway 192.168.123.1
*/
int main(int argc, char *argv[])
{
UnitreeCamera cam("trans_rect_config.yaml"); ///< init camera by device node number
if(!cam.isOpened()) ///< get camera open state
exit(EXIT_FAILURE);
cam.startCapture(true,false); ///< disable share memory sharing and able image h264 encoding
usleep(500000);
while(cam.isOpened())
{
cv::Mat left,right,feim;
if(!cam.getRectStereoFrame(left,right))
{
usleep(1000);
continue;
}
char key = cv::waitKey(10);
if(key == 27) // press ESC key
break;
}
cam.stopCapture(); ///< stop camera capturing
return 0;
}
/*
int main(int argc, char *argv[])
{
UnitreeCamera cam("trans_rect_config.yaml"); ///< init camera by device node number
if(!cam.isOpened()) ///< get camera open state
exit(EXIT_FAILURE);
cam.startCapture(true,false); ///< disable share memory sharing and able image h264 encoding
usleep(500000);
while(cam.isOpened())
{
cv::Mat frame;
std::chrono::microseconds t;
if(!cam.getRawFrame(frame, t)){ ///< get camera raw image
usleep(1000);
continue;
}
char key = cv::waitKey(10);
if(key == 27) // press ESC key
break;
}
cam.stopCapture(); ///< stop camera capturing
return 0;
}
*/