Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 11 additions & 53 deletions common/pipeline/ODDetection.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ namespace od

/** \brief The base class of all the detection.
*
* This is the base class of all the detection classes containing the detection information. All the ODDetector s return a collection of this class (in the form of ODDetections).
* Supports two modes: recognition (with type OD_DETECTION_RECOG) and classification (with type OD_DETECTION_CLASS). Along with the type, ODDetector sets an ID to identify what class or what instance of recognition is detected/recognied.
* This is the base class of all the detection classes containing the detection information. All the ODDetectors return a collection of this class (in the form of ODDetections).
* It supports two modes: recognition (with type OD_DETECTION_RECOG) and classification (with type OD_DETECTION_CLASS). Along with the type, ODDetector sets an ID to identify what class or what instance of recognition is detected/recognied.
*
* \author Kripasindhu Sarkar
*
Expand All @@ -57,14 +57,12 @@ namespace od
{
public:


OD_DEFINE_ENUM_WITH_STRING_CONVERSIONS(DetectionType, (OD_DETECTION_RECOG)(OD_DETECTION_CLASS)(OD_DETECTION_NULL))

virtual ~ODDetection()
{ }

ODDetection(DetectionType const &type_ = OD_DETECTION_NULL, std::string const &id_ = "", double confidence_ = 1) : type_(type_), id_(id_),
confidence_(confidence_)
ODDetection(DetectionType const &type_ = OD_DETECTION_NULL, std::string const &id_ = "", double confidence_ = 1) : type_(type_), id_(id_), confidence_(confidence_)
{ }

void printSelf()
Expand Down Expand Up @@ -101,8 +99,6 @@ namespace od
return confidence_;
}

/** \brief Get/Set the confidence of the detection. ODDetector can use this to provide confidence amnong several detections.
*/
void setConfidence(double confidence_)
{
ODDetection::confidence_ = confidence_;
Expand All @@ -123,6 +119,8 @@ namespace od
{
public:

/** \brief Making base class destructor virtual guarantees that the object of derived class is destructed properly.
*/
virtual ~ODDetection2D()
{ }

Expand Down Expand Up @@ -161,7 +159,6 @@ namespace od
ODDetection2D::metainfo_image_ = metainfo_image_;
}


Eigen::Vector3d location_2d_;
cv::Rect bounding_box_2d_;
cv::Mat metainfo_image_;
Expand All @@ -175,6 +172,9 @@ namespace od
class ODDetection3D : public virtual ODDetection
{
public:

/** \brief Making base class destructor virtual guarantees that the object of derived class is destructed properly.
*/
virtual ~ODDetection3D()
{ }

Expand All @@ -187,6 +187,7 @@ namespace od
{
ODDetection3D::location_3d_ = location_;
}

void setLocation(cv::Mat const &location_)
{
cv::cv2eigen(location_, this->location_3d_);
Expand All @@ -201,6 +202,7 @@ namespace od
{
ODDetection3D::orientation_ = pose_;
}

void setPose(cv::Mat const & pose_cv)
{
this->orientation_ = Eigen::Map<Eigen::Matrix3d>(pose_cv.clone().ptr<double>());
Expand Down Expand Up @@ -258,15 +260,6 @@ namespace od
typename pcl::PointCloud<pcl::PointXYZ>::Ptr metainfo_cluster_;
};

/** \brief Detection in 2D with complete information.
*
* \author Kripasindhu Sarkar
*
*/
class ODDetectionComplete: public ODDetection2D, public ODDetection3D
{
};

/** \brief The container class for ODDetection
*
* \author Kripasindhu Sarkar
Expand Down Expand Up @@ -330,9 +323,7 @@ namespace od
};




/** \brief The container class for ODDetection2D returned by ODDetector2D
/** \brief The container class for ODDetection2D returned by ODDetector2D
*
* \author Kripasindhu Sarkar
*
Expand Down Expand Up @@ -378,42 +369,9 @@ namespace od
{
public:

/*ODSceneImage renderMetainfo(ODSceneImage input)
{
//picking up random colors for different detection algorithm, if exist
std::map<std::string, cv::Scalar> color_map;
for(int i = 0; i < detections_.size(); i++)
{
if(color_map.find(detections_[i]->getId()) == color_map.end())
color_map[detections_[i]->getId()] = CV_RGB(rand()%255, rand()%255, rand()%255);
}

cv::Mat image = input.getCVImage().clone();
for(int i = 0; i < detections_.size(); i++)
{
ODDetections3D * detection = dynamic_cast<ODDetections3D *>(detections_[i]);
cv::rectangle(image, detection->bounding_box_2d_, color_map[detections_[i]->getId()], 2);
}
return ODSceneImage(image);
}*/


ODDetection3D * operator[](int i) { return dynamic_cast<ODDetection3D *>(detections_[i]); }
ODDetection3D * at(int i) { return dynamic_cast<ODDetection3D *>(detections_[i]); }
};

/** \brief The container class for ODDetectionComplete returned by ODDetector2DComplete
*
* \author Kripasindhu Sarkar
*
*/
class ODDetectionsComplete: public ODDetections
{
public:

ODDetectionComplete * operator[](int i) { return dynamic_cast<ODDetectionComplete *>(detections_[i]); }
ODDetectionComplete * at(int i) { return dynamic_cast <ODDetectionComplete *>(detections_[i]); }
};

}
#endif //OPENDETECTION_ODDETECTION_H
1 change: 1 addition & 0 deletions common/pipeline/ODDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Created by sarkar on 13.08.15.
//

#include "ODDetector.h"
5 changes: 3 additions & 2 deletions common/pipeline/ODDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ namespace od
{
/** \brief The main detector class; all special Detectors derives from this.
*
* Provides interface for two important function detect() and detectOmni(). detectOmni() performs a detection/recognition on the entire scene (unsegmented and unprocessed)
* and provides information about the detection as well as its exact location. detect() takes an 'object candidate' or a segmented/processed scene as an input and identifies if the entire scene is a detection.
* Provides interface for two important function detect() and detectOmni().
* detectOmni() performs a detection/recognition on the entire scene (unsegmented and unprocessed) and provides information about the detection as well as its exact location.
* detect() takes an 'object candidate' or a segmented/processed scene as an input and identifies if the entire scene is a detection.
*
* \author Kripasindhu Sarkar
*
Expand Down
12 changes: 8 additions & 4 deletions common/pipeline/ODScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef OPENDETECTION_SCENE_H
#define OPENDETECTION_SCENE_H

//#include <opencv2/core/core.hpp>
#include <opencv2/core/types.hpp>
#include <iostream>
#include <opencv2/imgcodecs.hpp>
Expand All @@ -41,7 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

namespace od
{
/** \brief Base class for Scenes. This contains information about the scenes. Scenes can be image scenes or point cloud scenes
/** \brief Base class for Scenes. This contains information about the scenes. Scenes can be image scenes or point cloud scenes.
*
* \author Kripasindhu Sarkar
*
Expand Down Expand Up @@ -113,8 +112,8 @@ namespace od
}

protected:
cv::Mat cvimage_;

cv::Mat cvimage_;
std::vector<cv::KeyPoint> keypoints_;
cv::Mat descriptors_;
bool is_trained_;
Expand Down Expand Up @@ -166,9 +165,14 @@ namespace od
ODScenePointCloud::point_cloud_ = point_cloud_;
}

void * getData() { return (void *)point_cloud_.get(); }
void * getData()
{
return (void *)point_cloud_.get();
}

protected:
PointCloudPtr point_cloud_;

};
}

Expand Down
4 changes: 1 addition & 3 deletions common/pipeline/ODTrainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef OPENDETECTION_TRAINER_H
#define OPENDETECTION_TRAINER_H

#include<iostream>
#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>

#include "ODAlgorithmBase.h"
#include "ObjectDetector.h"


namespace bf = boost::filesystem;

namespace od
Expand Down