# Revision history [back]

I had to add my own implementation to add noise to a depth image from a kinect camera. I simply added some gaussian noise to it and set some random pixels to zero. Can't really tell if this is a good solution or anyhow approximating the noise of a real camera, but anyway this is how I've done it:

data = rospy.wait_for_message('/camera/depth/image_raw', Image, timeout=5)
# change encoding of the image
bridge = CvBridge()
cv_image = bridge.imgmsg_to_cv2(data, desired_encoding="32FC1")
# convert to a numpy array
image = np.array(cv_image, dtype=np.float)
# adding noise to (simulated) depth image
image = image + np.random.normal(0.0, 10.0, image.shape)
# set approx. 5% of all pixels to zero
# normalizing image
cv2.normalize(image, image, 0, 255, cv2.NORM_MINMAX)


I had to add my own implementation to add noise to a depth image from a kinect camera. I did this in my python program, not in a custom C++ sensor plugin. I simply added some gaussian noise to it and set some random pixels to zero. Can't really tell if this is a good solution or anyhow approximating the noise of a real camera, but anyway this is how I've done it:

data = rospy.wait_for_message('/camera/depth/image_raw', Image, timeout=5)
# change encoding of the image
bridge = CvBridge()
cv_image = bridge.imgmsg_to_cv2(data, desired_encoding="32FC1")
# convert to a numpy array
image = np.array(cv_image, dtype=np.float)
# adding noise to (simulated) depth image
image = image + np.random.normal(0.0, 10.0, image.shape)
# set approx. 5% of all pixels to zero