wkentaro
3/21/2017 - 8:55 AM

Check loss-less of the compression

Check loss-less of the compression

<launch>

  <node name="nodelet_manager"
        pkg="nodelet" type="nodelet" args="manager" />

  <group ns="/right_hand_camera/rgb">
    <node name="republish_rgb_image_raw"
          pkg="image_transport" type="republish"
          args="compressed raw">
      <remap from="in" to="image_raw" />
      <remap from="out" to="/right_hand_camera_local/rgb/image_raw" />
    </node>
  </group>

  <group ns="/right_hand_camera/depth_registered">
    <node name="republish_depth_registered_image_raw"
          pkg="image_transport" type="republish"
          args="compressedDepth raw">
      <remap from="in" to="image_raw" />
      <remap from="out" to="/right_hand_camera_local/depth_registered/image_raw" />
    </node>
  </group>

</launch>
#!/usr/bin/env python

import cv_bridge
import message_filters
from sensor_msgs.msg import Image
import rospy
import numpy as np


def cb(msg1, msg2):
    bridge = cv_bridge.CvBridge()
    img1 = bridge.imgmsg_to_cv2(msg1)
    img2 = bridge.imgmsg_to_cv2(msg2)
    rospy.logerr(np.nanmean(np.abs(img1.astype(float) - img2.astype(float))))


rospy.init_node('check_loss_less')
sub1 = message_filters.Subscriber('~input1', Image)
sub2 = message_filters.Subscriber('~input2', Image)
fs = [sub1, sub2]
sync = message_filters.TimeSynchronizer(fs, queue_size=100)
sync.registerCallback(cb)
rospy.spin()