From 2a55d7f02263392db823dad0398b298c3e3c1199 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:16:06 +0530
Subject: [PATCH 01/28] Add files via upload
---
node1.py | 43 +++++++++++++++++++++++++++++++++++++++++++
node2.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++
node3.py | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 126 insertions(+)
create mode 100644 node1.py
create mode 100644 node2.py
create mode 100644 node3.py
diff --git a/node1.py b/node1.py
new file mode 100644
index 0000000..fc978b2
--- /dev/null
+++ b/node1.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def webcam_pub():
+ #To initialize the node
+ rospy.init_node('webcam_publisher', anonymous=True)
+ #Creating a publisher for the Webcam_image topic
+ image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
+ #publishing rate in Hz
+ rate = rospy.Rate(10)
+
+ #variable/objct to store CvBridge() class
+ bridge = CvBridge()
+ #it will open camera
+ camera = cv2.VideoCapture(0)
+
+ while not rospy.is_shutdown():
+ #it will capture frames
+ ret, frame = camera.read()
+
+ if ret:
+ try:
+ #converts image to ros msg
+ image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
+ #publish the image message
+ image_publisher.publish(image_msg)
+ except Exception as e:
+ rospy.logerr(e)
+
+ #It will maintain the publishing rate by sleeping
+ rate.sleep()
+
+ camera.release()
+
+if __name__ == '__main__':
+ try:
+ webcam_pub()
+ except rospy.ROSInterruptException:
+ pass
diff --git a/node2.py b/node2.py
new file mode 100644
index 0000000..2cefc6e
--- /dev/null
+++ b/node2.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+image_publisher = None
+
+def img_callback(msg):
+ global image_publisher
+
+ try:
+ #now convert the ros image into cv image
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
+ cropped_image = cv_image[108:396, 192:1088]
+ #again converting cv image to ros image message
+ cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
+
+ #publishes the cropped image
+ image_publisher.publish(cropped_msg)
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def img_cropper():
+ global image_publisher
+
+ #init_node command to initialize the node
+ rospy.init_node('image_cropper', anonymous=True)
+
+ #Creating a publisher for the cropped image topic
+ image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
+
+ # Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_img', Image, img_callback)
+
+ rospy.spin()
+
+if __name__ == '__main__':
+ try:
+ img_cropper()
+ except rospy.ROSInterruptException:
+ pass
diff --git a/node3.py b/node3.py
new file mode 100644
index 0000000..3909688
--- /dev/null
+++ b/node3.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def image_callback(msg):
+ try:
+ #converting the ros image message to opencv format
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #displays the cropped image
+ cv2.imshow("Webcam-Cropped-Image", cv_image)
+ cv2.waitKey(1) #Refresh display every 1 ms
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def image_viewer():
+ #initializing the node
+ rospy.init_node('image_viewer', anonymous=True)
+
+ #Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_cropped', Image, image_callback)
+
+ rospy.spin()
+
+ cv2.destroyAllWindows()
+
+if __name__ == '__main__':
+ try:
+ image_viewer()
+ except rospy.ROSInterruptException:
+ pass
From 5d79d4952165e925adb6aff90b91368299e08b8f Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:19:07 +0530
Subject: [PATCH 02/28] Create src
---
src | 1 +
1 file changed, 1 insertion(+)
create mode 100644 src
diff --git a/src b/src
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src
@@ -0,0 +1 @@
+
From 9efe0f65bb115f3ff293e133c2772526114b38ef Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:19:24 +0530
Subject: [PATCH 03/28] Delete src
---
src | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 src
diff --git a/src b/src
deleted file mode 100644
index 8b13789..0000000
--- a/src
+++ /dev/null
@@ -1 +0,0 @@
-
From 45c1c648d7e3dff67d01ce34fb216408c9347ef7 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:21:32 +0530
Subject: [PATCH 04/28] Delete node3.py
---
node3.py | 36 ------------------------------------
1 file changed, 36 deletions(-)
delete mode 100644 node3.py
diff --git a/node3.py b/node3.py
deleted file mode 100644
index 3909688..0000000
--- a/node3.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-def image_callback(msg):
- try:
- #converting the ros image message to opencv format
- bridge = CvBridge()
- cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
-
- #displays the cropped image
- cv2.imshow("Webcam-Cropped-Image", cv_image)
- cv2.waitKey(1) #Refresh display every 1 ms
-
- except Exception as e:
- rospy.logerr(e)
-
-def image_viewer():
- #initializing the node
- rospy.init_node('image_viewer', anonymous=True)
-
- #Creating a subscriber for the image topic
- rospy.Subscriber('Webcam_cropped', Image, image_callback)
-
- rospy.spin()
-
- cv2.destroyAllWindows()
-
-if __name__ == '__main__':
- try:
- image_viewer()
- except rospy.ROSInterruptException:
- pass
From ac4920fe753b56257fa9caecc7c86dcf8b20903c Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:21:44 +0530
Subject: [PATCH 05/28] Delete node2.py
---
node2.py | 47 -----------------------------------------------
1 file changed, 47 deletions(-)
delete mode 100644 node2.py
diff --git a/node2.py b/node2.py
deleted file mode 100644
index 2cefc6e..0000000
--- a/node2.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-image_publisher = None
-
-def img_callback(msg):
- global image_publisher
-
- try:
- #now convert the ros image into cv image
- bridge = CvBridge()
- cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
-
- #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
- cropped_image = cv_image[108:396, 192:1088]
- #again converting cv image to ros image message
- cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
-
- #publishes the cropped image
- image_publisher.publish(cropped_msg)
-
- except Exception as e:
- rospy.logerr(e)
-
-def img_cropper():
- global image_publisher
-
- #init_node command to initialize the node
- rospy.init_node('image_cropper', anonymous=True)
-
- #Creating a publisher for the cropped image topic
- image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
-
- # Creating a subscriber for the image topic
- rospy.Subscriber('Webcam_img', Image, img_callback)
-
- rospy.spin()
-
-if __name__ == '__main__':
- try:
- img_cropper()
- except rospy.ROSInterruptException:
- pass
From 21f0aeea553d7aa69fa1ee076cec8954812412b3 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:21:57 +0530
Subject: [PATCH 06/28] Delete node1.py
---
node1.py | 43 -------------------------------------------
1 file changed, 43 deletions(-)
delete mode 100644 node1.py
diff --git a/node1.py b/node1.py
deleted file mode 100644
index fc978b2..0000000
--- a/node1.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-def webcam_pub():
- #To initialize the node
- rospy.init_node('webcam_publisher', anonymous=True)
- #Creating a publisher for the Webcam_image topic
- image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
- #publishing rate in Hz
- rate = rospy.Rate(10)
-
- #variable/objct to store CvBridge() class
- bridge = CvBridge()
- #it will open camera
- camera = cv2.VideoCapture(0)
-
- while not rospy.is_shutdown():
- #it will capture frames
- ret, frame = camera.read()
-
- if ret:
- try:
- #converts image to ros msg
- image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
- #publish the image message
- image_publisher.publish(image_msg)
- except Exception as e:
- rospy.logerr(e)
-
- #It will maintain the publishing rate by sleeping
- rate.sleep()
-
- camera.release()
-
-if __name__ == '__main__':
- try:
- webcam_pub()
- except rospy.ROSInterruptException:
- pass
From 61dd7d67f79669beca64d28fa1e071b6a1907659 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:26:29 +0530
Subject: [PATCH 07/28] Create node1.py
---
src/node1.py | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 src/node1.py
diff --git a/src/node1.py b/src/node1.py
new file mode 100644
index 0000000..fc978b2
--- /dev/null
+++ b/src/node1.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def webcam_pub():
+ #To initialize the node
+ rospy.init_node('webcam_publisher', anonymous=True)
+ #Creating a publisher for the Webcam_image topic
+ image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
+ #publishing rate in Hz
+ rate = rospy.Rate(10)
+
+ #variable/objct to store CvBridge() class
+ bridge = CvBridge()
+ #it will open camera
+ camera = cv2.VideoCapture(0)
+
+ while not rospy.is_shutdown():
+ #it will capture frames
+ ret, frame = camera.read()
+
+ if ret:
+ try:
+ #converts image to ros msg
+ image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
+ #publish the image message
+ image_publisher.publish(image_msg)
+ except Exception as e:
+ rospy.logerr(e)
+
+ #It will maintain the publishing rate by sleeping
+ rate.sleep()
+
+ camera.release()
+
+if __name__ == '__main__':
+ try:
+ webcam_pub()
+ except rospy.ROSInterruptException:
+ pass
From ade7549039a94d33c12971e65fd9d1efc0c1e709 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:26:56 +0530
Subject: [PATCH 08/28] Add files via upload
---
src/node2.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++
src/node3.py | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100644 src/node2.py
create mode 100644 src/node3.py
diff --git a/src/node2.py b/src/node2.py
new file mode 100644
index 0000000..2cefc6e
--- /dev/null
+++ b/src/node2.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+image_publisher = None
+
+def img_callback(msg):
+ global image_publisher
+
+ try:
+ #now convert the ros image into cv image
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
+ cropped_image = cv_image[108:396, 192:1088]
+ #again converting cv image to ros image message
+ cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
+
+ #publishes the cropped image
+ image_publisher.publish(cropped_msg)
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def img_cropper():
+ global image_publisher
+
+ #init_node command to initialize the node
+ rospy.init_node('image_cropper', anonymous=True)
+
+ #Creating a publisher for the cropped image topic
+ image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
+
+ # Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_img', Image, img_callback)
+
+ rospy.spin()
+
+if __name__ == '__main__':
+ try:
+ img_cropper()
+ except rospy.ROSInterruptException:
+ pass
diff --git a/src/node3.py b/src/node3.py
new file mode 100644
index 0000000..3909688
--- /dev/null
+++ b/src/node3.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def image_callback(msg):
+ try:
+ #converting the ros image message to opencv format
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #displays the cropped image
+ cv2.imshow("Webcam-Cropped-Image", cv_image)
+ cv2.waitKey(1) #Refresh display every 1 ms
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def image_viewer():
+ #initializing the node
+ rospy.init_node('image_viewer', anonymous=True)
+
+ #Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_cropped', Image, image_callback)
+
+ rospy.spin()
+
+ cv2.destroyAllWindows()
+
+if __name__ == '__main__':
+ try:
+ image_viewer()
+ except rospy.ROSInterruptException:
+ pass
From e705d4d2f46a580af096cc61dde30e9ae6754020 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:32:10 +0530
Subject: [PATCH 09/28] Create README.md
---
src/README.md | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 src/README.md
diff --git a/src/README.md b/src/README.md
new file mode 100644
index 0000000..0794fc8
--- /dev/null
+++ b/src/README.md
@@ -0,0 +1,2 @@
+Name: Manoj Kumar
+Roll No: 220625
From db26c53fabac2dfbef9ed17123ee65b5299cb06e Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:32:55 +0530
Subject: [PATCH 10/28] Create node1.py
---
src/Assignment 1/node1.py | 43 +++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 src/Assignment 1/node1.py
diff --git a/src/Assignment 1/node1.py b/src/Assignment 1/node1.py
new file mode 100644
index 0000000..fc978b2
--- /dev/null
+++ b/src/Assignment 1/node1.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def webcam_pub():
+ #To initialize the node
+ rospy.init_node('webcam_publisher', anonymous=True)
+ #Creating a publisher for the Webcam_image topic
+ image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
+ #publishing rate in Hz
+ rate = rospy.Rate(10)
+
+ #variable/objct to store CvBridge() class
+ bridge = CvBridge()
+ #it will open camera
+ camera = cv2.VideoCapture(0)
+
+ while not rospy.is_shutdown():
+ #it will capture frames
+ ret, frame = camera.read()
+
+ if ret:
+ try:
+ #converts image to ros msg
+ image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
+ #publish the image message
+ image_publisher.publish(image_msg)
+ except Exception as e:
+ rospy.logerr(e)
+
+ #It will maintain the publishing rate by sleeping
+ rate.sleep()
+
+ camera.release()
+
+if __name__ == '__main__':
+ try:
+ webcam_pub()
+ except rospy.ROSInterruptException:
+ pass
From 084eff6b25220bf8e8e6d660f260e8be5f97ed7f Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:33:19 +0530
Subject: [PATCH 11/28] Add files via upload
---
src/Assignment 1/node2.py | 47 +++++++++++++++++++++++++++++++++++++++
src/Assignment 1/node3.py | 36 ++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100644 src/Assignment 1/node2.py
create mode 100644 src/Assignment 1/node3.py
diff --git a/src/Assignment 1/node2.py b/src/Assignment 1/node2.py
new file mode 100644
index 0000000..2cefc6e
--- /dev/null
+++ b/src/Assignment 1/node2.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+image_publisher = None
+
+def img_callback(msg):
+ global image_publisher
+
+ try:
+ #now convert the ros image into cv image
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
+ cropped_image = cv_image[108:396, 192:1088]
+ #again converting cv image to ros image message
+ cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
+
+ #publishes the cropped image
+ image_publisher.publish(cropped_msg)
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def img_cropper():
+ global image_publisher
+
+ #init_node command to initialize the node
+ rospy.init_node('image_cropper', anonymous=True)
+
+ #Creating a publisher for the cropped image topic
+ image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
+
+ # Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_img', Image, img_callback)
+
+ rospy.spin()
+
+if __name__ == '__main__':
+ try:
+ img_cropper()
+ except rospy.ROSInterruptException:
+ pass
diff --git a/src/Assignment 1/node3.py b/src/Assignment 1/node3.py
new file mode 100644
index 0000000..3909688
--- /dev/null
+++ b/src/Assignment 1/node3.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def image_callback(msg):
+ try:
+ #converting the ros image message to opencv format
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #displays the cropped image
+ cv2.imshow("Webcam-Cropped-Image", cv_image)
+ cv2.waitKey(1) #Refresh display every 1 ms
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def image_viewer():
+ #initializing the node
+ rospy.init_node('image_viewer', anonymous=True)
+
+ #Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_cropped', Image, image_callback)
+
+ rospy.spin()
+
+ cv2.destroyAllWindows()
+
+if __name__ == '__main__':
+ try:
+ image_viewer()
+ except rospy.ROSInterruptException:
+ pass
From f33cfc0401dc0a35030392e4e6f77809b8c288ee Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:33:37 +0530
Subject: [PATCH 12/28] Delete node1.py
---
src/node1.py | 43 -------------------------------------------
1 file changed, 43 deletions(-)
delete mode 100644 src/node1.py
diff --git a/src/node1.py b/src/node1.py
deleted file mode 100644
index fc978b2..0000000
--- a/src/node1.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-def webcam_pub():
- #To initialize the node
- rospy.init_node('webcam_publisher', anonymous=True)
- #Creating a publisher for the Webcam_image topic
- image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
- #publishing rate in Hz
- rate = rospy.Rate(10)
-
- #variable/objct to store CvBridge() class
- bridge = CvBridge()
- #it will open camera
- camera = cv2.VideoCapture(0)
-
- while not rospy.is_shutdown():
- #it will capture frames
- ret, frame = camera.read()
-
- if ret:
- try:
- #converts image to ros msg
- image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
- #publish the image message
- image_publisher.publish(image_msg)
- except Exception as e:
- rospy.logerr(e)
-
- #It will maintain the publishing rate by sleeping
- rate.sleep()
-
- camera.release()
-
-if __name__ == '__main__':
- try:
- webcam_pub()
- except rospy.ROSInterruptException:
- pass
From 97d5d6f9aae4d46d9a533dcd6e91d65732cbd13a Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:33:47 +0530
Subject: [PATCH 13/28] Delete node2.py
---
src/node2.py | 47 -----------------------------------------------
1 file changed, 47 deletions(-)
delete mode 100644 src/node2.py
diff --git a/src/node2.py b/src/node2.py
deleted file mode 100644
index 2cefc6e..0000000
--- a/src/node2.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-image_publisher = None
-
-def img_callback(msg):
- global image_publisher
-
- try:
- #now convert the ros image into cv image
- bridge = CvBridge()
- cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
-
- #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
- cropped_image = cv_image[108:396, 192:1088]
- #again converting cv image to ros image message
- cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
-
- #publishes the cropped image
- image_publisher.publish(cropped_msg)
-
- except Exception as e:
- rospy.logerr(e)
-
-def img_cropper():
- global image_publisher
-
- #init_node command to initialize the node
- rospy.init_node('image_cropper', anonymous=True)
-
- #Creating a publisher for the cropped image topic
- image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
-
- # Creating a subscriber for the image topic
- rospy.Subscriber('Webcam_img', Image, img_callback)
-
- rospy.spin()
-
-if __name__ == '__main__':
- try:
- img_cropper()
- except rospy.ROSInterruptException:
- pass
From 1a0e646a9ea4cceebe71e2bf5d8f27c831da52f8 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:33:59 +0530
Subject: [PATCH 14/28] Delete node3.py
---
src/node3.py | 36 ------------------------------------
1 file changed, 36 deletions(-)
delete mode 100644 src/node3.py
diff --git a/src/node3.py b/src/node3.py
deleted file mode 100644
index 3909688..0000000
--- a/src/node3.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-def image_callback(msg):
- try:
- #converting the ros image message to opencv format
- bridge = CvBridge()
- cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
-
- #displays the cropped image
- cv2.imshow("Webcam-Cropped-Image", cv_image)
- cv2.waitKey(1) #Refresh display every 1 ms
-
- except Exception as e:
- rospy.logerr(e)
-
-def image_viewer():
- #initializing the node
- rospy.init_node('image_viewer', anonymous=True)
-
- #Creating a subscriber for the image topic
- rospy.Subscriber('Webcam_cropped', Image, image_callback)
-
- rospy.spin()
-
- cv2.destroyAllWindows()
-
-if __name__ == '__main__':
- try:
- image_viewer()
- except rospy.ROSInterruptException:
- pass
From 43a48e929f5bfc6a8009f99fbb013a1dce565328 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:35:02 +0530
Subject: [PATCH 15/28] Create node1.py
---
Assignment 1/src/node1.py | 43 +++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 Assignment 1/src/node1.py
diff --git a/Assignment 1/src/node1.py b/Assignment 1/src/node1.py
new file mode 100644
index 0000000..fc978b2
--- /dev/null
+++ b/Assignment 1/src/node1.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def webcam_pub():
+ #To initialize the node
+ rospy.init_node('webcam_publisher', anonymous=True)
+ #Creating a publisher for the Webcam_image topic
+ image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
+ #publishing rate in Hz
+ rate = rospy.Rate(10)
+
+ #variable/objct to store CvBridge() class
+ bridge = CvBridge()
+ #it will open camera
+ camera = cv2.VideoCapture(0)
+
+ while not rospy.is_shutdown():
+ #it will capture frames
+ ret, frame = camera.read()
+
+ if ret:
+ try:
+ #converts image to ros msg
+ image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
+ #publish the image message
+ image_publisher.publish(image_msg)
+ except Exception as e:
+ rospy.logerr(e)
+
+ #It will maintain the publishing rate by sleeping
+ rate.sleep()
+
+ camera.release()
+
+if __name__ == '__main__':
+ try:
+ webcam_pub()
+ except rospy.ROSInterruptException:
+ pass
From edb115cc992991552ef6115ce7684529cef3687e Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:35:21 +0530
Subject: [PATCH 16/28] Add files via upload
---
Assignment 1/src/node2.py | 47 +++++++++++++++++++++++++++++++++++++++
Assignment 1/src/node3.py | 36 ++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100644 Assignment 1/src/node2.py
create mode 100644 Assignment 1/src/node3.py
diff --git a/Assignment 1/src/node2.py b/Assignment 1/src/node2.py
new file mode 100644
index 0000000..2cefc6e
--- /dev/null
+++ b/Assignment 1/src/node2.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+image_publisher = None
+
+def img_callback(msg):
+ global image_publisher
+
+ try:
+ #now convert the ros image into cv image
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
+ cropped_image = cv_image[108:396, 192:1088]
+ #again converting cv image to ros image message
+ cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
+
+ #publishes the cropped image
+ image_publisher.publish(cropped_msg)
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def img_cropper():
+ global image_publisher
+
+ #init_node command to initialize the node
+ rospy.init_node('image_cropper', anonymous=True)
+
+ #Creating a publisher for the cropped image topic
+ image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
+
+ # Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_img', Image, img_callback)
+
+ rospy.spin()
+
+if __name__ == '__main__':
+ try:
+ img_cropper()
+ except rospy.ROSInterruptException:
+ pass
diff --git a/Assignment 1/src/node3.py b/Assignment 1/src/node3.py
new file mode 100644
index 0000000..3909688
--- /dev/null
+++ b/Assignment 1/src/node3.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def image_callback(msg):
+ try:
+ #converting the ros image message to opencv format
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #displays the cropped image
+ cv2.imshow("Webcam-Cropped-Image", cv_image)
+ cv2.waitKey(1) #Refresh display every 1 ms
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def image_viewer():
+ #initializing the node
+ rospy.init_node('image_viewer', anonymous=True)
+
+ #Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_cropped', Image, image_callback)
+
+ rospy.spin()
+
+ cv2.destroyAllWindows()
+
+if __name__ == '__main__':
+ try:
+ image_viewer()
+ except rospy.ROSInterruptException:
+ pass
From 40a6afb11a1be435c044a18d1a50fd593af17437 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:35:54 +0530
Subject: [PATCH 17/28] Delete Assignment 1/src directory
---
Assignment 1/src/node1.py | 43 -----------------------------------
Assignment 1/src/node2.py | 47 ---------------------------------------
Assignment 1/src/node3.py | 36 ------------------------------
3 files changed, 126 deletions(-)
delete mode 100644 Assignment 1/src/node1.py
delete mode 100644 Assignment 1/src/node2.py
delete mode 100644 Assignment 1/src/node3.py
diff --git a/Assignment 1/src/node1.py b/Assignment 1/src/node1.py
deleted file mode 100644
index fc978b2..0000000
--- a/Assignment 1/src/node1.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-def webcam_pub():
- #To initialize the node
- rospy.init_node('webcam_publisher', anonymous=True)
- #Creating a publisher for the Webcam_image topic
- image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
- #publishing rate in Hz
- rate = rospy.Rate(10)
-
- #variable/objct to store CvBridge() class
- bridge = CvBridge()
- #it will open camera
- camera = cv2.VideoCapture(0)
-
- while not rospy.is_shutdown():
- #it will capture frames
- ret, frame = camera.read()
-
- if ret:
- try:
- #converts image to ros msg
- image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
- #publish the image message
- image_publisher.publish(image_msg)
- except Exception as e:
- rospy.logerr(e)
-
- #It will maintain the publishing rate by sleeping
- rate.sleep()
-
- camera.release()
-
-if __name__ == '__main__':
- try:
- webcam_pub()
- except rospy.ROSInterruptException:
- pass
diff --git a/Assignment 1/src/node2.py b/Assignment 1/src/node2.py
deleted file mode 100644
index 2cefc6e..0000000
--- a/Assignment 1/src/node2.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-image_publisher = None
-
-def img_callback(msg):
- global image_publisher
-
- try:
- #now convert the ros image into cv image
- bridge = CvBridge()
- cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
-
- #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
- cropped_image = cv_image[108:396, 192:1088]
- #again converting cv image to ros image message
- cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
-
- #publishes the cropped image
- image_publisher.publish(cropped_msg)
-
- except Exception as e:
- rospy.logerr(e)
-
-def img_cropper():
- global image_publisher
-
- #init_node command to initialize the node
- rospy.init_node('image_cropper', anonymous=True)
-
- #Creating a publisher for the cropped image topic
- image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
-
- # Creating a subscriber for the image topic
- rospy.Subscriber('Webcam_img', Image, img_callback)
-
- rospy.spin()
-
-if __name__ == '__main__':
- try:
- img_cropper()
- except rospy.ROSInterruptException:
- pass
diff --git a/Assignment 1/src/node3.py b/Assignment 1/src/node3.py
deleted file mode 100644
index 3909688..0000000
--- a/Assignment 1/src/node3.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-def image_callback(msg):
- try:
- #converting the ros image message to opencv format
- bridge = CvBridge()
- cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
-
- #displays the cropped image
- cv2.imshow("Webcam-Cropped-Image", cv_image)
- cv2.waitKey(1) #Refresh display every 1 ms
-
- except Exception as e:
- rospy.logerr(e)
-
-def image_viewer():
- #initializing the node
- rospy.init_node('image_viewer', anonymous=True)
-
- #Creating a subscriber for the image topic
- rospy.Subscriber('Webcam_cropped', Image, image_callback)
-
- rospy.spin()
-
- cv2.destroyAllWindows()
-
-if __name__ == '__main__':
- try:
- image_viewer()
- except rospy.ROSInterruptException:
- pass
From 20278c066aeffe22ea15430f400d47db87eacf10 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:38:34 +0530
Subject: [PATCH 18/28] Create README.md
---
src/Assignment 1/README.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 src/Assignment 1/README.md
diff --git a/src/Assignment 1/README.md b/src/Assignment 1/README.md
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/Assignment 1/README.md
@@ -0,0 +1 @@
+
From 0347b041d89b45aa8a21cc82a12effe05377155f Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:39:01 +0530
Subject: [PATCH 19/28] Delete README.md
---
src/README.md | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 src/README.md
diff --git a/src/README.md b/src/README.md
deleted file mode 100644
index 0794fc8..0000000
--- a/src/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-Name: Manoj Kumar
-Roll No: 220625
From b9f3e86e9c9ec4856a285993af1797c9d55c029d Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:45:31 +0530
Subject: [PATCH 20/28] Create README.md
---
Assignment 1/README.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Assignment 1/README.md
diff --git a/Assignment 1/README.md b/Assignment 1/README.md
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/Assignment 1/README.md
@@ -0,0 +1 @@
+
From 99072d28afd770254f4bfba1d7d346e31965084e Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:45:51 +0530
Subject: [PATCH 21/28] Create node1.py
---
Assignment 1/src/node1.py | 43 +++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 Assignment 1/src/node1.py
diff --git a/Assignment 1/src/node1.py b/Assignment 1/src/node1.py
new file mode 100644
index 0000000..fc978b2
--- /dev/null
+++ b/Assignment 1/src/node1.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def webcam_pub():
+ #To initialize the node
+ rospy.init_node('webcam_publisher', anonymous=True)
+ #Creating a publisher for the Webcam_image topic
+ image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
+ #publishing rate in Hz
+ rate = rospy.Rate(10)
+
+ #variable/objct to store CvBridge() class
+ bridge = CvBridge()
+ #it will open camera
+ camera = cv2.VideoCapture(0)
+
+ while not rospy.is_shutdown():
+ #it will capture frames
+ ret, frame = camera.read()
+
+ if ret:
+ try:
+ #converts image to ros msg
+ image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
+ #publish the image message
+ image_publisher.publish(image_msg)
+ except Exception as e:
+ rospy.logerr(e)
+
+ #It will maintain the publishing rate by sleeping
+ rate.sleep()
+
+ camera.release()
+
+if __name__ == '__main__':
+ try:
+ webcam_pub()
+ except rospy.ROSInterruptException:
+ pass
From 3ee1166ac6487cb4f82d346fa0dade81fe7028c7 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:46:13 +0530
Subject: [PATCH 22/28] Add files via upload
---
Assignment 1/src/node2.py | 47 +++++++++++++++++++++++++++++++++++++++
Assignment 1/src/node3.py | 36 ++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
create mode 100644 Assignment 1/src/node2.py
create mode 100644 Assignment 1/src/node3.py
diff --git a/Assignment 1/src/node2.py b/Assignment 1/src/node2.py
new file mode 100644
index 0000000..2cefc6e
--- /dev/null
+++ b/Assignment 1/src/node2.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+image_publisher = None
+
+def img_callback(msg):
+ global image_publisher
+
+ try:
+ #now convert the ros image into cv image
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
+ cropped_image = cv_image[108:396, 192:1088]
+ #again converting cv image to ros image message
+ cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
+
+ #publishes the cropped image
+ image_publisher.publish(cropped_msg)
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def img_cropper():
+ global image_publisher
+
+ #init_node command to initialize the node
+ rospy.init_node('image_cropper', anonymous=True)
+
+ #Creating a publisher for the cropped image topic
+ image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
+
+ # Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_img', Image, img_callback)
+
+ rospy.spin()
+
+if __name__ == '__main__':
+ try:
+ img_cropper()
+ except rospy.ROSInterruptException:
+ pass
diff --git a/Assignment 1/src/node3.py b/Assignment 1/src/node3.py
new file mode 100644
index 0000000..3909688
--- /dev/null
+++ b/Assignment 1/src/node3.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import rospy
+from sensor_msgs.msg import Image
+from cv_bridge import CvBridge
+import cv2
+
+def image_callback(msg):
+ try:
+ #converting the ros image message to opencv format
+ bridge = CvBridge()
+ cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
+
+ #displays the cropped image
+ cv2.imshow("Webcam-Cropped-Image", cv_image)
+ cv2.waitKey(1) #Refresh display every 1 ms
+
+ except Exception as e:
+ rospy.logerr(e)
+
+def image_viewer():
+ #initializing the node
+ rospy.init_node('image_viewer', anonymous=True)
+
+ #Creating a subscriber for the image topic
+ rospy.Subscriber('Webcam_cropped', Image, image_callback)
+
+ rospy.spin()
+
+ cv2.destroyAllWindows()
+
+if __name__ == '__main__':
+ try:
+ image_viewer()
+ except rospy.ROSInterruptException:
+ pass
From 8c2a8bda8d35926bc25804078a32f0c71851dbf9 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Tue, 30 May 2023 23:48:53 +0530
Subject: [PATCH 23/28] Delete src/Assignment 1 directory
---
src/Assignment 1/README.md | 1 -
src/Assignment 1/node1.py | 43 ----------------------------------
src/Assignment 1/node2.py | 47 --------------------------------------
src/Assignment 1/node3.py | 36 -----------------------------
4 files changed, 127 deletions(-)
delete mode 100644 src/Assignment 1/README.md
delete mode 100644 src/Assignment 1/node1.py
delete mode 100644 src/Assignment 1/node2.py
delete mode 100644 src/Assignment 1/node3.py
diff --git a/src/Assignment 1/README.md b/src/Assignment 1/README.md
deleted file mode 100644
index 8b13789..0000000
--- a/src/Assignment 1/README.md
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/Assignment 1/node1.py b/src/Assignment 1/node1.py
deleted file mode 100644
index fc978b2..0000000
--- a/src/Assignment 1/node1.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-def webcam_pub():
- #To initialize the node
- rospy.init_node('webcam_publisher', anonymous=True)
- #Creating a publisher for the Webcam_image topic
- image_publisher = rospy.Publisher('Webcam_img', Image, queue_size=10)
- #publishing rate in Hz
- rate = rospy.Rate(10)
-
- #variable/objct to store CvBridge() class
- bridge = CvBridge()
- #it will open camera
- camera = cv2.VideoCapture(0)
-
- while not rospy.is_shutdown():
- #it will capture frames
- ret, frame = camera.read()
-
- if ret:
- try:
- #converts image to ros msg
- image_msg = bridge.cv2_to_imgmsg(frame, "bgr8")
- #publish the image message
- image_publisher.publish(image_msg)
- except Exception as e:
- rospy.logerr(e)
-
- #It will maintain the publishing rate by sleeping
- rate.sleep()
-
- camera.release()
-
-if __name__ == '__main__':
- try:
- webcam_pub()
- except rospy.ROSInterruptException:
- pass
diff --git a/src/Assignment 1/node2.py b/src/Assignment 1/node2.py
deleted file mode 100644
index 2cefc6e..0000000
--- a/src/Assignment 1/node2.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-image_publisher = None
-
-def img_callback(msg):
- global image_publisher
-
- try:
- #now convert the ros image into cv image
- bridge = CvBridge()
- cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
-
- #cropping by 30% pixels [y1:y2, x1:x2] where (x1,y1) is the coordinate of bottom left corner and (x2,y2) is of top right corner
- cropped_image = cv_image[108:396, 192:1088]
- #again converting cv image to ros image message
- cropped_msg = bridge.cv2_to_imgmsg(cropped_image, "bgr8")
-
- #publishes the cropped image
- image_publisher.publish(cropped_msg)
-
- except Exception as e:
- rospy.logerr(e)
-
-def img_cropper():
- global image_publisher
-
- #init_node command to initialize the node
- rospy.init_node('image_cropper', anonymous=True)
-
- #Creating a publisher for the cropped image topic
- image_publisher = rospy.Publisher('Webcam_cropped', Image, queue_size=10)
-
- # Creating a subscriber for the image topic
- rospy.Subscriber('Webcam_img', Image, img_callback)
-
- rospy.spin()
-
-if __name__ == '__main__':
- try:
- img_cropper()
- except rospy.ROSInterruptException:
- pass
diff --git a/src/Assignment 1/node3.py b/src/Assignment 1/node3.py
deleted file mode 100644
index 3909688..0000000
--- a/src/Assignment 1/node3.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python3
-
-import rospy
-from sensor_msgs.msg import Image
-from cv_bridge import CvBridge
-import cv2
-
-def image_callback(msg):
- try:
- #converting the ros image message to opencv format
- bridge = CvBridge()
- cv_image = bridge.imgmsg_to_cv2(msg, "bgr8")
-
- #displays the cropped image
- cv2.imshow("Webcam-Cropped-Image", cv_image)
- cv2.waitKey(1) #Refresh display every 1 ms
-
- except Exception as e:
- rospy.logerr(e)
-
-def image_viewer():
- #initializing the node
- rospy.init_node('image_viewer', anonymous=True)
-
- #Creating a subscriber for the image topic
- rospy.Subscriber('Webcam_cropped', Image, image_callback)
-
- rospy.spin()
-
- cv2.destroyAllWindows()
-
-if __name__ == '__main__':
- try:
- image_viewer()
- except rospy.ROSInterruptException:
- pass
From 5591090749f6163e8b5905aa2f1114a155336ceb Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Wed, 31 May 2023 00:06:25 +0530
Subject: [PATCH 24/28] Update README.md
---
Assignment 1/README.md | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Assignment 1/README.md b/Assignment 1/README.md
index 8b13789..79e8883 100644
--- a/Assignment 1/README.md
+++ b/Assignment 1/README.md
@@ -1 +1,11 @@
+What I have done for this Assignment:
+#Learnt about openCv, classes, methods and about various dependencies to create/build a package.
+#Create a package named image_processes in catkin_ws/src folder by running command line in terminal as catkin_create-pkg image_processes rospy roscpp cv_bridge stdg_msgs and more.
+#Now run the catkin_make command in catkin_ws folder
+#now created the node1.py node2.py node3.py files in catkin_ws/src/image_processes/src path
+#now make the files executable by running command chmod +x node1.py and similarily for others two
+#in node1.py imports the required libraries and then created a webcam-pub function which gopen the camera gather the image data and then publish it to the Webcam
+-img topic
+#in node2.py I sunscribed to Webcam_img topic then publish a Webcam_cropped topic which has the iamge data 30% reduced by pixels
+#in node3.py I subscribed the Webcam_cropped topic then show that cropped image
From cc1a583dfffe0c4de58d1b26b06f28df17597bfc Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Wed, 31 May 2023 20:45:57 +0530
Subject: [PATCH 25/28] Update README.md
---
Assignment 1/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Assignment 1/README.md b/Assignment 1/README.md
index 79e8883..728ac78 100644
--- a/Assignment 1/README.md
+++ b/Assignment 1/README.md
@@ -8,4 +8,4 @@ What I have done for this Assignment:
#in node1.py imports the required libraries and then created a webcam-pub function which gopen the camera gather the image data and then publish it to the Webcam
-img topic
#in node2.py I sunscribed to Webcam_img topic then publish a Webcam_cropped topic which has the iamge data 30% reduced by pixels
-#in node3.py I subscribed the Webcam_cropped topic then show that cropped image
+#in node3.py I subscribed the Webcam_cropped topic then show that cropped to image
From 523224b3bac94bbb19d2b44fdeba737215124ee6 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Mon, 5 Jun 2023 16:47:19 +0530
Subject: [PATCH 26/28] Create image_cropping.launch
---
Assignment 1/launch/image_cropping.launch | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 Assignment 1/launch/image_cropping.launch
diff --git a/Assignment 1/launch/image_cropping.launch b/Assignment 1/launch/image_cropping.launch
new file mode 100644
index 0000000..7ac55c5
--- /dev/null
+++ b/Assignment 1/launch/image_cropping.launch
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From a697fad916fb80dedd5096a1c798a872042c8021 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Mon, 5 Jun 2023 16:49:59 +0530
Subject: [PATCH 27/28] Update image_cropping.launch
---
Assignment 1/launch/image_cropping.launch | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Assignment 1/launch/image_cropping.launch b/Assignment 1/launch/image_cropping.launch
index 7ac55c5..3a6cabc 100644
--- a/Assignment 1/launch/image_cropping.launch
+++ b/Assignment 1/launch/image_cropping.launch
@@ -1,20 +1,20 @@
-
+
-
+
-
+
From 77ad62ffeb662796f02b4b6149b3b995dc591a87 Mon Sep 17 00:00:00 2001
From: MKR-360 <86281458+MKR-360@users.noreply.github.com>
Date: Mon, 12 Jun 2023 22:05:15 +0530
Subject: [PATCH 28/28] Update README.md
edit launch file description
---
Assignment 1/README.md | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/Assignment 1/README.md b/Assignment 1/README.md
index 728ac78..545a79d 100644
--- a/Assignment 1/README.md
+++ b/Assignment 1/README.md
@@ -5,7 +5,16 @@ What I have done for this Assignment:
#Now run the catkin_make command in catkin_ws folder
#now created the node1.py node2.py node3.py files in catkin_ws/src/image_processes/src path
#now make the files executable by running command chmod +x node1.py and similarily for others two
-#in node1.py imports the required libraries and then created a webcam-pub function which gopen the camera gather the image data and then publish it to the Webcam
+#in node1.py imports the required libraries and then created a webcam-pub function which open the camera gather the image data and then publish it to the Webcam
-img topic
-#in node2.py I sunscribed to Webcam_img topic then publish a Webcam_cropped topic which has the iamge data 30% reduced by pixels
+#in node2.py I subscribed to Webcam_img topic then publish a Webcam_cropped topic which has the image data 30% reduced by pixels. To crop, first we have to convert Ros image into cv image then crop it again convert into Ros image.
#in node3.py I subscribed the Webcam_cropped topic then show that cropped to image
+#Finally created a launch file which launches all the three nodes at once.
+
+
+
+#resources:-
+wiki.ros.org
+ChatGPT
+askubuntu.com
+stackoverflow.com
\ No newline at end of file