mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-16 22:35:51 +08:00
Fix interface, add documentation
This commit is contained in:
@@ -53,25 +53,51 @@ namespace cv
|
||||
{
|
||||
namespace xobjdetect
|
||||
{
|
||||
//! @addtogroup xobjdetect
|
||||
//! @{
|
||||
|
||||
|
||||
/** @brief WaldBoost detector
|
||||
*/
|
||||
class CV_EXPORTS WBDetector {
|
||||
public:
|
||||
/** @brief Read detector from FileNode.
|
||||
@param node FileNode for input
|
||||
*/
|
||||
virtual void read(const FileNode &node) = 0;
|
||||
|
||||
/** @brief Write detector to FileStorage.
|
||||
@param fs FileStorage for output
|
||||
*/
|
||||
virtual void write(FileStorage &fs) const = 0;
|
||||
|
||||
/** @brief Train WaldBoost detector
|
||||
@param pos_samples Path to directory with cropped positive samples
|
||||
@param neg_imgs Path to directory with negative (background) images
|
||||
*/
|
||||
virtual void train(
|
||||
const std::string& pos_samples,
|
||||
const std::string& neg_imgs) = 0;
|
||||
|
||||
/** @brief Detect objects on image using WaldBoost detector
|
||||
@param img Input image for detection
|
||||
@param bboxes Bounding boxes coordinates output vector
|
||||
@param confidences Confidence values for bounding boxes output vector
|
||||
*/
|
||||
virtual void detect(
|
||||
const Mat& img,
|
||||
std::vector<Rect> &bboxes,
|
||||
std::vector<double> &confidences) = 0;
|
||||
|
||||
/** @brief Create instance of WBDetector
|
||||
*/
|
||||
static Ptr<WBDetector> create();
|
||||
|
||||
virtual ~WBDetector(){}
|
||||
};
|
||||
|
||||
CV_EXPORTS Ptr<WBDetector> create_wbdetector();
|
||||
|
||||
//! @}
|
||||
|
||||
} /* namespace xobjdetect */
|
||||
} /* namespace cv */
|
||||
|
@@ -365,7 +365,7 @@ int WaldBoost::predict(Ptr<CvFeatureEvaluator> eval, float *h) const
|
||||
|
||||
void WaldBoost::write(FileStorage &fs) const
|
||||
{
|
||||
fs << "waldboost" << "{";
|
||||
fs << "{";
|
||||
fs << "waldboost_params"
|
||||
<< "{" << "weak_count" << weak_count_ << "}";
|
||||
|
||||
|
@@ -212,7 +212,8 @@ void WBDetectorImpl::detect(
|
||||
assert(confidences.size() == bboxes.size());
|
||||
}
|
||||
|
||||
Ptr<WBDetector> create_wbdetector()
|
||||
Ptr<WBDetector>
|
||||
WBDetector::create()
|
||||
{
|
||||
return Ptr<WBDetector>(new WBDetectorImpl());
|
||||
}
|
||||
|
@@ -16,11 +16,12 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
string mode = argv[1];
|
||||
Ptr<WBDetector> detector = create_wbdetector();
|
||||
Ptr<WBDetector> detector = WBDetector::create();
|
||||
if (mode == "train") {
|
||||
assert(argc == 5);
|
||||
detector->train(argv[3], argv[4]);
|
||||
FileStorage fs(argv[2], FileStorage::WRITE);
|
||||
fs << "waldboost";
|
||||
detector->write(fs);
|
||||
} else if (mode == "detect") {
|
||||
assert(argc == 6);
|
||||
@@ -28,7 +29,7 @@ int main(int argc, char **argv)
|
||||
vector<double> confidences;
|
||||
Mat img = imread(argv[3], CV_LOAD_IMAGE_GRAYSCALE);
|
||||
FileStorage fs(argv[2], FileStorage::READ);
|
||||
detector->read(fs["waldboost"]);
|
||||
detector->read(fs.getFirstTopLevelNode());
|
||||
detector->detect(img, bboxes, confidences);
|
||||
|
||||
FILE *fhandle = fopen(argv[5], "a");
|
||||
|
Reference in New Issue
Block a user