-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #866 from iKrishneel/master
Nodelet to perform Sliding Window Object detection
- Loading branch information
Showing
18 changed files
with
1,065 additions
and
4 deletions.
There are no files selected for viewing
Submodule .travis
updated
2 files
+3 −1 | travis.sh | |
+13 −1 | travis_jenkins.py |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
|
||
# set up parameters that we care about | ||
PACKAGE = 'jsk_perception' | ||
try: | ||
import imp | ||
imp.find_module(PACKAGE) | ||
from dynamic_reconfigure.parameter_generator_catkin import *; | ||
except: | ||
import roslib; roslib.load_manifest(PACKAGE) | ||
from dynamic_reconfigure.parameter_generator import *; | ||
|
||
from math import pi | ||
|
||
gen = ParameterGenerator () | ||
|
||
gen.add("sliding_window_width", int_t, 0,"sliding window detector width", 32, 32, 32) | ||
gen.add("sliding_window_height", int_t, 0,"sliding window detector height", 64, 64, 64) | ||
gen.add("image_downsize", int_t, 0,"factor for resizing the image", 1, 1, 2) | ||
|
||
gen.add("svm_model_name", str_t, 0, "trained svm model name with path", "svm.xml") | ||
gen.add("dataset_directory", str_t, 0, "directory for training data","NO TRAINING SET") | ||
|
||
gen.add("scaling_factor", double_t, 0,"sliding window scaling factor in each stack", -0.05, -0.90, 0.9) | ||
gen.add("stack_size", int_t, 0, "number of image stack in pyramid", 4, 1, 15) | ||
gen.add("sliding_window_increment", int_t, 0, "number of pixels to increment the window", 8, 1, 32) | ||
|
||
|
||
exit (gen.generate (PACKAGE, "jsk_perception", "SlidingWindowObjectDetector")) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions
44
jsk_perception/include/jsk_perception/histogram_of_oriented_gradients.h
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
#ifndef _HISTOGRAM_OF_ORIENTED_GRADIENTS_H_ | ||
#define _HISTOGRAM_OF_ORIENTED_GRADIENTS_H_ | ||
|
||
// OpenCV Header Directives | ||
#include <opencv2/opencv.hpp> | ||
#include <opencv2/highgui/highgui.hpp> | ||
#include <opencv2/imgproc/imgproc.hpp> | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
class HOGFeatureDescriptor { | ||
|
||
// HOG Configuration Params | ||
#define N_BINS 9 | ||
#define ANGLE 180.0 | ||
#define BINS_ANGLE (ANGLE / N_BINS) | ||
#define CELL 8 | ||
#define BLOCK 2 | ||
|
||
private: | ||
virtual void bilinearBinVoting( | ||
const float &, int &, int &); | ||
virtual void imageGradient( | ||
const cv::Mat &, cv::Mat &); | ||
virtual cv::Mat blockGradient( | ||
const int, const int, cv::Mat &); | ||
virtual cv::Mat orientationistogram( | ||
const cv::Mat&, const int &, const int &, bool = false); | ||
virtual void getHOG( | ||
const cv::Mat &, cv::Mat &, cv::Mat &); | ||
template<typename T> | ||
T computeHOGHistogramDistances( | ||
const cv::Mat &, std::vector<cv::Mat> &, | ||
const int = CV_COMP_BHATTACHARYYA); | ||
|
||
public: | ||
HOGFeatureDescriptor(); | ||
virtual cv::Mat computeHOG( | ||
const cv::Mat &); | ||
}; | ||
|
||
#endif // _HISTOGRAM_OF_ORIENTED_GRADIENTS_H_ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// -*- mode: c++ -*- | ||
/********************************************************************* | ||
* Software License Agreement (BSD License) | ||
* | ||
* Copyright (c) 2015, JSK Lab | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/o2r other materials provided | ||
* with the distribution. | ||
* * Neither the name of the JSK Lab nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*********************************************************************/ | ||
|
||
#ifndef JSK_PERCEPTION_SKELETONIZATION_H | ||
#define JSK_PERCEPTION_SKELETONIZATION_H | ||
|
||
// ROS Header Directives | ||
#include <ros/ros.h> | ||
#include <ros/console.h> | ||
|
||
#include <jsk_topic_tools/diagnostic_nodelet.h> | ||
#include <sensor_msgs/Image.h> | ||
#include <cv_bridge/cv_bridge.h> | ||
#include <sensor_msgs/image_encodings.h> | ||
|
||
// OpenCV Header Directives | ||
#include <opencv2/imgproc/imgproc.hpp> | ||
#include <opencv2/highgui/highgui.hpp> | ||
|
||
namespace jsk_perception | ||
{ | ||
class Skeletonization: public jsk_topic_tools::DiagnosticNodelet | ||
{ | ||
public: | ||
Skeletonization(): DiagnosticNodelet("Skeletonization") {} | ||
|
||
protected: | ||
virtual void onInit(); | ||
virtual void subscribe(); | ||
virtual void unsubscribe(); | ||
virtual void imageCallback(const sensor_msgs::Image::ConstPtr&); | ||
virtual void skeletonization(cv::Mat &); | ||
virtual void iterativeThinning( | ||
cv::Mat&, int); | ||
|
||
boost::mutex mutex_; | ||
ros::Subscriber sub_; | ||
ros::Publisher pub_image_; | ||
|
||
private: | ||
enum { EVEN, ODD }; | ||
}; | ||
} | ||
|
||
#endif // JSK_PERCEPTION_SKELETONIZATION_H | ||
|
103 changes: 103 additions & 0 deletions
103
jsk_perception/include/jsk_perception/sliding_window_object_detector.h
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
#ifndef JSK_PERCEPTION_SLIDING_WINDOW_OBJECT_DETECTOR_H | ||
#define JSK_PERCEPTION_SLIDING_WINDOW_OBJECT_DETECTOR_H | ||
|
||
#include <jsk_topic_tools/diagnostic_nodelet.h> | ||
#include <jsk_perception/histogram_of_oriented_gradients.h> | ||
#include <jsk_recognition_msgs/RectArray.h> | ||
|
||
#include <jsk_recognition_msgs/ClusterPointIndices.h> | ||
// #include <jsk_pcl_ros/pcl_conversion_util.h> | ||
|
||
#include <dynamic_reconfigure/server.h> | ||
#include <jsk_perception/SlidingWindowObjectDetectorConfig.h> | ||
|
||
#include <pcl/point_types.h> | ||
|
||
#include <ros/ros.h> | ||
#include <ros/console.h> | ||
|
||
#include <image_transport/image_transport.h> | ||
#include <cv_bridge/cv_bridge.h> | ||
#include <sensor_msgs/image_encodings.h> | ||
#include <sensor_msgs/PointCloud2.h> | ||
|
||
#include <iostream> | ||
#include <vector> | ||
#include <string> | ||
#include <fstream> | ||
#include <map> | ||
#include <algorithm> | ||
#include <utility> | ||
|
||
namespace jsk_perception | ||
{ | ||
class SlidingWindowObjectDetector: public jsk_topic_tools::DiagnosticNodelet, | ||
public HOGFeatureDescriptor | ||
{ | ||
public: | ||
SlidingWindowObjectDetector(): DiagnosticNodelet("SlidingWindowObjectDetector") | ||
{ | ||
// loadTrainedDetectorModel(); | ||
} | ||
|
||
virtual void loadTrainedDetectorModel(); | ||
virtual void trainObjectClassifier(); | ||
virtual void readDataset( | ||
std::string, std::vector<cv::Mat> &, | ||
cv::Mat &, bool = false, const int = 0); | ||
virtual void extractFeatures( | ||
const std::vector<cv::Mat> &, cv::Mat &); | ||
virtual void trainBinaryClassSVM( | ||
const cv::Mat &, const cv::Mat &); | ||
virtual std::vector<cv::Rect_<int> > runObjectRecognizer( | ||
cv::Mat &, const cv::Size, const float, const int, const int); | ||
virtual void objectRecognizer( | ||
const cv::Mat &, std::multimap<float, cv::Rect_<int> > &, | ||
const cv::Size, const int = 16); | ||
virtual void pyramidialScaling( | ||
cv::Size &, const float); | ||
virtual std::vector<cv::Rect_<int> > nonMaximumSuppression( | ||
std::multimap<float, cv::Rect_<int> > &, const float); | ||
|
||
void convertCvRectToJSKRectArray( | ||
const std::vector<cv::Rect_<int> > &, | ||
jsk_recognition_msgs::RectArray &, const int, const cv::Size ); | ||
void concatenateCVMat( | ||
const cv::Mat &, const cv::Mat &, cv::Mat &, bool = true); | ||
virtual void configCallback( | ||
jsk_perception::SlidingWindowObjectDetectorConfig &, uint32_t); | ||
|
||
protected: | ||
virtual void imageCb( | ||
const sensor_msgs::ImageConstPtr&); | ||
|
||
virtual void onInit(); | ||
virtual void subscribe(); | ||
virtual void unsubscribe(); | ||
|
||
boost::mutex mutex_; | ||
ros::Subscriber sub_; | ||
ros::Publisher pub_image_; | ||
ros::Publisher pub_rects_; | ||
ros::ServiceClient nms_client_; | ||
|
||
int swindow_x; | ||
int swindow_y; | ||
float scale_; | ||
int stack_size_; | ||
int incrementor_; | ||
int downsize_; | ||
|
||
std::string model_name_; | ||
std::string dataset_path_; | ||
boost::shared_ptr<cv::SVM> supportVectorMachine_; | ||
boost::shared_ptr<dynamic_reconfigure::Server< | ||
jsk_perception::SlidingWindowObjectDetectorConfig> > srv_; | ||
|
||
}; | ||
|
||
} // namespace jsk_perception | ||
|
||
|
||
#endif // JSK_PERCEPTION_SLIDING_WINDOW_OBJECT_DETECTOR_H |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<launch> | ||
<node pkg="jsk_perception" type="edge_detector" name="edge_detector"> | ||
<remap from="image" to="/camera/rgb/image_rect_color" /> | ||
</node> | ||
<node pkg="jsk_perception" type="dilate_mask_image" name="dilate_mask_image"> | ||
<remap from="~input" to="/edge/image" /> | ||
</node> | ||
<node pkg="jsk_perception" type="skeletonization" name="skeletonization"> | ||
<remap from="~input" to="/dilate_mask_image/output" /> | ||
</node> | ||
<node pkg="image_view" type="image_view" name="edge_view" > | ||
<remap from="image" to="/edge/image" /> | ||
</node> | ||
<node pkg="rqt_reconfigure" type="rqt_reconfigure" name="edge_reconfigure" /> | ||
</launch> |
13 changes: 13 additions & 0 deletions
13
jsk_perception/launch/sliding_window_object_detector.launch
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<launch> | ||
<group> | ||
<node pkg="jsk_perception" type="sliding_window_object_detector" name="sliding_window_object_detector" output="screen"> | ||
</node> | ||
<node pkg="jsk_perception" type="non_maximum_suppression.py" name="non_maximum_suppression" output="screen"> | ||
<remap from="non_maximum_suppression" to="/sliding_window_object_detector/non_maximum_suppression" /> | ||
</node> | ||
</group> | ||
<node pkg="image_view" type="image_view" name="detector" > | ||
<remap from="image" to="/sliding_window_object_detector/output/image" /> | ||
</node> | ||
<node pkg="rqt_reconfigure" type="rqt_reconfigure" name="detector_reconfigure" /> | ||
</launch> |
Oops, something went wrong.