Skip to content

Commit

Permalink
#2 Fixed some problems
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroMaia21 committed Nov 6, 2024
1 parent 12ee862 commit bee7092
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion hefestus/hefestus_perception/src/lane_detection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

import cv2
import numpy as np
Expand Down
31 changes: 23 additions & 8 deletions hefestus/hefestus_sensing/src/main_vision.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
import rospy
import cv2
from sensor_msgs.msg import Image
Expand All @@ -9,16 +9,31 @@ def mainVisionNode():
img_bridge = CvBridge()

cam = cv2.VideoCapture(2)

if not cam.isOpened():
rospy.logerr("Camera could not be opened.")
return

rate = rospy.Rate(1) # 10hz
rate = rospy.Rate(1) # 1hz

while not rospy.is_shutdown():
_, img_raw = cam.read()

img_message = img_bridge.cv2_to_imgmsg(img_raw, "bgr8")
try:
while not rospy.is_shutdown():
ret, img_raw = cam.read()

img_Pub.publish(img_message)
rate.sleep()
if not ret:
rospy.logerr("Failed to capture image")
break

img_message = img_bridge.cv2_to_imgmsg(img_raw, "bgr8")
img_Pub.publish(img_message)
rate.sleep()

except rospy.ROSInterruptException:
rospy.loginfo("ROS Interrupt Exception occurred.")

finally:
cam.release()
rospy.loginfo("Camera released.")

if __name__ == "__main__":
try:
Expand Down
2 changes: 1 addition & 1 deletion hefestus/hefestus_sensing/src/sensing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
import cv2
from cv_bridge import CvBridge, CvBridgeError
import rospy
Expand Down

0 comments on commit bee7092

Please sign in to comment.