ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

jesusy's profile - activity

2020-12-23 12:53:01 -0500 received badge  Famous Question (source)
2020-06-02 06:00:11 -0500 received badge  Notable Question (source)
2020-05-29 05:52:00 -0500 received badge  Famous Question (source)
2020-05-15 05:42:14 -0500 received badge  Notable Question (source)
2020-05-15 05:42:14 -0500 received badge  Popular Question (source)
2020-04-10 14:30:08 -0500 received badge  Popular Question (source)
2020-04-10 00:44:15 -0500 commented answer Face detection with usb_cam

Thank you, I had not done chmod +x the file, beginner mistake.

2020-04-10 00:41:52 -0500 received badge  Supporter (source)
2020-04-10 00:39:33 -0500 marked best answer Face detection with usb_cam

Hello, I'm following this video on How to use ros usb cam for face detection. In the las part, when I run:

rosrun detect_face ros_face_detection.py

And yes, I changed the location of the haar cascades files. It gives me this error:

yepez@user:~/catkin_ws$ rosrun detect_face ros_face_detection.py

[rosrun] Couldn't find executable named ros_face_detection.py below /home/yepez/catkin_w/src/RobotOperatingSystem/detect_face
[rosrun] Found the following, but they're either not files
[rosrun] or not executable:
[rosrun]   /home/yepez/catkin_ws/src/RobotOperatingSystem/detect_face/src/ros_face_detection.py`

This is the ros_face_detection.py file:

 -----#!/usr/bin/env python

   import rospy
   import cv2
   from std_msgs.msg import String
   from sensor_msgs.msg import Image
   from cv_bridge import CvBridge, CvBridgeError
   import sys
   import numpy as np

   bridge = CvBridge()
   face_cascade = cv2.CascadeClassifier('/home/yepez/catkin_ws/src/RobotOperatingSystem/detect_face/src/haarcascade_frontalface_default.xml')
   eye_cascade = cv2.CascadeClassifier('/home/yepez/catkin_ws/src/RobotOperatingSystem/detect_face/src/haarcascade_eye.xml')

  def image_callback(ros_image):
  print ('got an image')
  global bridge
  #convert ros_image into an opencv-compatible image
  try:
      img = bridge.imgmsg_to_cv2(ros_image, "bgr8")
  except CvBridgeError as e:
      print(e)
  #from now on, you can work exactly like with opencv

  gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

  faces = face_cascade.detectMultiScale(gray, 1.3, 5)
  for (x,y,w,h) in faces:
      img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
      roi_gray = gray[y:y+h, x:x+w]
      roi_color = img[y:y+h, x:x+w]
      eyes = eye_cascade.detectMultiScale(roi_gray)
      for (ex,ey,ew,eh) in eyes:
          cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)
  font = cv2.FONT_HERSHEY_SIMPLEX
  cv2.putText(img,'Face Detection with ROS & OpenCV!',(15,450), font, 1,(255,255,255),2,cv2.LINE_AA)
  cv2.imshow('img',img)
  cv2.waitKey(3)


 def main(args):
  rospy.init_node('image_converter', anonymous=True)
  #for turtlebot3 waffle
  #image_topic="/camera/rgb/image_raw/compressed"
  #for usb cam
  #image_topic="/usb_cam/image_raw"
  image_sub = rospy.Subscriber("/usb_cam/image_raw",Image, image_callback)
  try:
   rospy.spin()
  except KeyboardInterrupt:
   print("Shutting down")
  cv2.destroyAllWindows()

if __name__ == '__main__':
    main(sys.argv)

Thanks in advance for the help.

2020-04-10 00:39:33 -0500 received badge  Scholar (source)
2020-04-09 22:39:13 -0500 edited question Face detection with usb_cam

Face detection with usb_cam Hello, I'm following this video on How to use ros usb cam for face detection. In the las par

2020-04-09 22:33:15 -0500 asked a question Face detection with usb_cam

Face detection with usb_cam Hello, I'm following this video on How to use ros usb cam for face detection. In the las par

2020-03-26 11:41:14 -0500 asked a question [Err] [Plugin.hh:178] Failed to load plugin libgazebo_light_sensor_plugin.so

[Err] [Plugin.hh:178] Failed to load plugin libgazebo_light_sensor_plugin.so Hello, I'm a beginner trying to follow thi