From 785c87f154923ac515755965aa933f82d05b59a5 Mon Sep 17 00:00:00 2001 From: slimeth Date: Tue, 15 Dec 2020 14:36:22 +0100 Subject: [PATCH] enabled optical flow in camera example --- flightros/launch/camera/camera.rviz | 22 +++++++++++++++++----- flightros/src/camera/camera.cpp | 12 +++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/flightros/launch/camera/camera.rviz b/flightros/launch/camera/camera.rviz index e5843213f4..3dcff85c8c 100644 --- a/flightros/launch/camera/camera.rviz +++ b/flightros/launch/camera/camera.rviz @@ -7,7 +7,7 @@ Panels: - /Global Options1 - /Status1 Splitter Ratio: 0.5 - Tree Height: 184 + Tree Height: 190 - Class: rviz/Selection Name: Selection - Class: rviz/Tool Properties @@ -88,6 +88,18 @@ Visualization Manager: Transport Hint: raw Unreliable: false Value: true + - Class: rviz/Image + Enabled: true + Image Topic: /opticalflow + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Image + Normalize Range: true + Queue Size: 2 + Transport Hint: raw + Unreliable: false + Value: true Enabled: true Global Options: Background Color: 48; 48; 48 @@ -139,12 +151,12 @@ Visualization Manager: Window Geometry: Displays: collapsed: false - Height: 1124 + Height: 1130 Hide Left Dock: false Hide Right Dock: true Image: collapsed: false - QMainWindow State: 000000ff00000000fd00000004000000000000075a0000013bfc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c00610079007301000002cd0000013b000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000354fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d00000354000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b2000000000000000000000002000008000000028afc010000000afb0000000a0049006d0061006700650100000000000002090000005e00fffffffb0000000a0049006d006100670065010000020f000003090000005e00fffffffb0000000a0049006d006100670065010000051e000002e20000005e00fffffffb0000000a0049006d0061006700650100000559000002a70000000000000000fb0000000a0049006d00610067006501000001e3000001e00000000000000000fb0000000a0049006d00610067006501000003c9000001e20000000000000000fb0000000a0049006d00610067006501000005a0000001e00000000000000000fb0000000a0049006d00610067006500000005c7000001b90000000000000000fb0000000a0049006d00610067006501000005b1000001cf0000000000000000fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000080000000039fc0100000002fb0000000800540069006d0065010000000000000800000002eb00fffffffb0000000800540069006d00650100000000000004500000000000000000000000a00000013b00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + QMainWindow State: 000000ff00000000fd00000004000000000000075a00000141fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c00610079007301000002cd00000141000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000354fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d00000354000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b2000000000000000000000002000007800000028afc010000000bfb0000000a0049006d0061006700650100000000000001c90000005e00fffffffb0000000a0049006d00610067006501000001cf000001ea0000005e00fffffffb0000000a0049006d00610067006501000003bf000002040000005e00fffffffb0000000a0049006d00610067006501000005c9000001b70000005e00fffffffb0000000a0049006d0061006700650100000559000002a70000000000000000fb0000000a0049006d00610067006501000001e3000001e00000000000000000fb0000000a0049006d00610067006501000003c9000001e20000000000000000fb0000000a0049006d00610067006501000005a0000001e00000000000000000fb0000000a0049006d00610067006500000005c7000001b90000000000000000fb0000000a0049006d00610067006501000005b1000001cf0000000000000000fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000078000000039fc0100000002fb0000000800540069006d0065010000000000000780000002eb00fffffffb0000000800540069006d00650100000000000004500000000000000000000000200000014100000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 Selection: collapsed: false Time: @@ -153,6 +165,6 @@ Window Geometry: collapsed: false Views: collapsed: true - Width: 2048 + Width: 1920 X: 0 - Y: 74 + Y: 0 diff --git a/flightros/src/camera/camera.cpp b/flightros/src/camera/camera.cpp index 56d2b9b399..dcef29fd22 100644 --- a/flightros/src/camera/camera.cpp +++ b/flightros/src/camera/camera.cpp @@ -100,13 +100,11 @@ int main(int argc, char *argv[]) { segmentation_msg->header.stamp = timestamp; segmentation_pub.publish(segmentation_msg); - // // The current optical flow is not correct. - // // you can still visualize it by uncomment the following code. - // rgb_camera->getOpticalFlow(img); - // sensor_msgs::ImagePtr opticflow_msg = - // cv_bridge::CvImage(std_msgs::Header(), "bgr8", img).toImageMsg(); - // opticflow_msg->header.stamp = timestamp; - // opticalflow_pub.publish(opticflow_msg); + rgb_camera->getOpticalFlow(img); + sensor_msgs::ImagePtr opticflow_msg = + cv_bridge::CvImage(std_msgs::Header(), "bgr8", img).toImageMsg(); + opticflow_msg->header.stamp = timestamp; + opticalflow_pub.publish(opticflow_msg); frame_id += 1; }