From 1302ff3c1633892a2fe904729bb150b24ea2da84 Mon Sep 17 00:00:00 2001 From: ravich2_7183 Date: Mon, 16 Jan 2017 13:27:09 +0530 Subject: [PATCH 1/2] Updated code from cv to cv2. --- camera_image/package.xml | 2 ++ camera_image/scripts/ip_camera.py | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/camera_image/package.xml b/camera_image/package.xml index 7e39486..4a24894 100644 --- a/camera_image/package.xml +++ b/camera_image/package.xml @@ -12,10 +12,12 @@ rospy sensor_msgs std_msgs + cv_bridge rospy sensor_msgs std_msgs + cv_bridge diff --git a/camera_image/scripts/ip_camera.py b/camera_image/scripts/ip_camera.py index c03fbb2..18bd45c 100644 --- a/camera_image/scripts/ip_camera.py +++ b/camera_image/scripts/ip_camera.py @@ -40,11 +40,10 @@ def __init__(self, url): if a!=-1 and b!=-1: jpg = ip_camera.bytes[a:b+2] ip_camera.bytes= ip_camera.bytes[b+2:] - i = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8),cv2.CV_LOAD_IMAGE_COLOR) - image_message = cv.fromarray(i) - ip_camera.image_pub.publish(ip_camera.bridge.cv_to_imgmsg(image_message, "bgr8")) + image_message = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8),cv2.CV_LOAD_IMAGE_COLOR) + ip_camera.image_pub.publish(ip_camera.bridge.cv2_to_imgmsg(image_message, "bgr8")) if args.gui: - cv2.imshow('IP Camera Publisher Cam',i) + cv2.imshow('IP Camera Publisher Cam',image_message) if cv2.waitKey(1) ==27: # wait until ESC key is pressed in the GUI window to stop it exit(0) From ff2c4ae0410b943788c1f7ef2398627ea7d4bfc6 Mon Sep 17 00:00:00 2001 From: ravich2_7183 Date: Mon, 16 Jan 2017 13:36:53 +0530 Subject: [PATCH 2/2] Added README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a8f367 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +## To run: +python camera_image/scripts/ip_camera.py -u http://192.168.100.2:8080/video + +replace ip address with your camera's. + +## To test frame rate: +rostopic hz --window=1000 /camera_image