Skip to content

Commit

Permalink
Added id to CheckForObjects action.
Browse files Browse the repository at this point in the history
Former-commit-id: 5a1d80077e6ac68352512cff7441c1f84637d250
  • Loading branch information
mbjelonic committed Jan 11, 2017
1 parent 89ee33f commit db7e361
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion darknet_ros/include/darknet_ros/YoloObjectDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class YoloObjectDetector
* Run YOLO and detect obstacles.
* @param[in] fullFrame image of current camera frame.
*/
void runYolo(cv::Mat &fullFrame);
void runYolo(cv::Mat &fullFrame, int id = 0);

/*!
* Callback of camera.
Expand Down
8 changes: 5 additions & 3 deletions darknet_ros/src/YoloObjectDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void YoloObjectDetector::drawBoxes(cv::Mat &inputFrame, std::vector<RosBox_> &ro
}
}

void YoloObjectDetector::runYolo(cv::Mat &fullFrame)
void YoloObjectDetector::runYolo(cv::Mat &fullFrame, int id)
{
ROS_INFO("[YoloObjectDetector] runYolo().");

Expand Down Expand Up @@ -233,6 +233,7 @@ void YoloObjectDetector::runYolo(cv::Mat &fullFrame)
{
ROS_DEBUG("[YoloObjectDetector] check for objects in image.");
darknet_ros_msgs::CheckForObjectsResult objectsActionResult;
objectsActionResult.id = id;
objectsActionResult.boundingBoxes = boundingBoxesResults_;
checkForObjectsActionServer_->setSucceeded(objectsActionResult,"Send bounding boxes.");
}
Expand Down Expand Up @@ -281,7 +282,8 @@ void YoloObjectDetector::checkForObjectsActionGoalCB()
{
ROS_INFO("[YoloObjectDetector] Start check for objects action.");

sensor_msgs::Image imageAction = checkForObjectsActionServer_->acceptNewGoal()->image;
boost::shared_ptr<const darknet_ros_msgs::CheckForObjectsGoal> imageActionPtr = checkForObjectsActionServer_->acceptNewGoal();
sensor_msgs::Image imageAction = imageActionPtr->image;

cv_bridge::CvImagePtr cam_image;

Expand All @@ -300,7 +302,7 @@ void YoloObjectDetector::checkForObjectsActionGoalCB()
camImageCopy_ = cam_image->image.clone();
frameWidth_ = cam_image->image.size().width;
frameHeight_ = cam_image->image.size().height;
runYolo(cam_image->image);
runYolo(cam_image->image, imageActionPtr->id);
}
return;
}
Expand Down
2 changes: 2 additions & 0 deletions darknet_ros_msgs/action/CheckForObjects.action
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Check if objects in image

# Goal definition
int16 id
sensor_msgs/Image image

---
# Result definition
int16 id
darknet_ros_msgs/BoundingBoxes boundingBoxes

---
Expand Down

0 comments on commit db7e361

Please sign in to comment.