Created
March 28, 2018 09:23
-
-
Save ahmdrz/f3b87baada40a534965a672d02b9b673 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rospy | |
import cv_bridge | |
import json | |
from saam_pose_estimation.srv import PoseEstimator | |
class PoseEstimation: | |
def __init__(self, service_name='saam_pose_estimation'): | |
rospy.wait_for_service(service_name) | |
self.service = rospy.ServiceProxy(service_name, PoseEstimator) | |
self.bridge = cv_bridge.CvBridge() | |
def detect(self, image): | |
image_h, image_w = image.shape[:2] | |
encoded_image = self.bridge.cv2_to_imgmsg(image, encoding="passthrough") | |
resp = self.service(input_image=encoded_image) | |
resp = resp.objects_json.data | |
resp = json.loads(resp) | |
for i in range(len(resp)): | |
for j in resp[i].keys(): | |
resp[i][j][0] = int(image_w * resp[i][j][0]) | |
resp[i][j][1] = int(image_h * resp[i][j][1]) | |
return resp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment