Commit 5e048d1f authored by Andrey Kamaev's avatar Andrey Kamaev

Move C API of opencv_objdetect to separate file

Also move cv::linemod to own header
parent e5a33723
......@@ -64,11 +64,10 @@
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/photo/photo_c.h"
#include "opencv2/video/tracking_c.h"
#include "opencv2/objdetect/objdetect_c.h"
#include "opencv2/legacy.hpp"
#include "opencv2/legacy/compat.hpp"
#include "opencv2/objdetect.hpp"
#if !defined(CV_IMPL)
#define CV_IMPL extern "C"
#endif //CV_IMPL
......
......@@ -55,5 +55,6 @@
#include "opencv2/highgui.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/objdetect.hpp"
#endif
......@@ -50,12 +50,11 @@
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/photo/photo_c.h"
#include "opencv2/video/tracking_c.h"
#include "opencv2/objdetect/objdetect_c.h"
#include "opencv2/legacy.hpp"
#include "opencv2/legacy/compat.hpp"
#include "opencv2/legacy/blobtrack.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/contrib.hpp"
#endif
......
......@@ -48,6 +48,8 @@
#include "opencv2/features2d.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/core/core_c.h"
#include <ostream>
#ifdef __cplusplus
......
This diff is collapsed.
This diff is collapsed.
#ifndef _LSVM_ROUTINE_H_
#define _LSVM_ROUTINE_H_
#include "opencv2/objdetect/objdetect_c.h"
#include "_lsvm_types.h"
#include "_lsvm_error.h"
......
#ifndef LSVM_PARSER
#define LSVM_PARSER
#include "opencv2/objdetect/objdetect_c.h"
#include "_lsvm_types.h"
......
......@@ -43,6 +43,7 @@
#include <cstdio>
#include "cascadedetect.hpp"
#include "opencv2/objdetect/objdetect_c.h"
#if defined (LOG_CASCADE_STATISTIC)
struct Logger
......
#include "precomp.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/objdetect/objdetect_c.h"
#include <deque>
#include <algorithm>
class Sampler {
......
......@@ -43,6 +43,7 @@
#include "precomp.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/objdetect/objdetect_c.h"
#include <stdio.h>
#if CV_SSE2
......
......@@ -41,6 +41,7 @@
//M*/
#include "precomp.hpp"
#include "opencv2/core/core_c.h"
#include <cstdio>
#include <iterator>
......@@ -2862,7 +2863,7 @@ void HOGDescriptor::readALTModel(String modelfile)
String eerr("file not exist");
String efile(__FILE__);
String efunc(__FUNCTION__);
throw Exception(CV_StsError, eerr, efile, efunc, __LINE__);
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
}
char version_buffer[10];
if (!fread (&version_buffer,sizeof(char),10,modelfl))
......@@ -2870,13 +2871,13 @@ void HOGDescriptor::readALTModel(String modelfile)
String eerr("version?");
String efile(__FILE__);
String efunc(__FUNCTION__);
throw Exception(CV_StsError, eerr, efile, efunc, __LINE__);
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
}
if(strcmp(version_buffer,"V6.01")) {
String eerr("version doesnot match");
String efile(__FILE__);
String efunc(__FUNCTION__);
throw Exception(CV_StsError, eerr, efile, efunc, __LINE__);
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
}
/* read version number */
int version = 0;
......
#include "precomp.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/objdetect/objdetect_c.h"
#include "_lsvmparser.h"
#include "_lsvm_matching.h"
......
......@@ -66,7 +66,7 @@ static inline int getLabel(int quantized)
case 64: return 6;
case 128: return 7;
default:
CV_Error(CV_StsBadArg, "Invalid value of quantized parameter");
CV_Error(Error::StsBadArg, "Invalid value of quantized parameter");
return -1; //avoid warning
}
}
......@@ -1398,17 +1398,17 @@ void Detector::match(const std::vector<Mat>& sources, float threshold, std::vect
if (quantized_images.needed())
quantized_images.create(1, static_cast<int>(pyramid_levels * modalities.size()), CV_8U);
assert(sources.size() == modalities.size());
CV_Assert(sources.size() == modalities.size());
// Initialize each modality with our sources
std::vector< Ptr<QuantizedPyramid> > quantizers;
for (int i = 0; i < (int)modalities.size(); ++i){
Mat mask, source;
source = sources[i];
if(!masks.empty()){
assert(masks.size() == modalities.size());
CV_Assert(masks.size() == modalities.size());
mask = masks[i];
}
assert(mask.empty() || mask.size() == source.size());
CV_Assert(mask.empty() || mask.size() == source.size());
quantizers.push_back(modalities[i]->process(source, mask));
}
// pyramid level -> modality -> quantization
......
#include "precomp.hpp"
#include "opencv2/objdetect/objdetect_c.h"
#include "_lsvm_matching.h"
#include <stdio.h>
......
......@@ -41,6 +41,7 @@
#include "test_precomp.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/objdetect/objdetect_c.h"
using namespace cv;
using namespace std;
......@@ -117,7 +118,7 @@ int CV_DetectorTest::prepareData( FileStorage& _fs )
// fn[TOTAL_NO_PAIR_E] >> eps.totalNoPair;
// read detectors
if( fn[DETECTOR_NAMES].node->data.seq != 0 )
if( fn[DETECTOR_NAMES].size() != 0 )
{
FileNodeIterator it = fn[DETECTOR_NAMES].begin();
for( ; it != fn[DETECTOR_NAMES].end(); )
......@@ -132,7 +133,7 @@ int CV_DetectorTest::prepareData( FileStorage& _fs )
// read images filenames and images
string dataPath = ts->get_data_path();
if( fn[IMAGE_FILENAMES].node->data.seq != 0 )
if( fn[IMAGE_FILENAMES].size() != 0 )
{
for( FileNodeIterator it = fn[IMAGE_FILENAMES].begin(); it != fn[IMAGE_FILENAMES].end(); )
{
......@@ -210,7 +211,7 @@ void CV_DetectorTest::run( int )
{
char buf[10];
sprintf( buf, "%s%d", "img_", ii );
cvWriteComment( validationFS.fs, buf, 0 );
//cvWriteComment( validationFS.fs, buf, 0 );
validationFS << *it;
}
validationFS << "]"; // IMAGE_FILENAMES
......@@ -316,7 +317,7 @@ int CV_DetectorTest::validate( int detectorIdx, vector<vector<Rect> >& objects )
string imageIdxStr = buf;
FileNode node = validationFS.getFirstTopLevelNode()[VALIDATION][detectorNames[detectorIdx]][imageIdxStr];
vector<Rect> valRects;
if( node.node->data.seq != 0 )
if( node.size() != 0 )
{
for( FileNodeIterator it2 = node.begin(); it2 != node.end(); )
{
......@@ -410,12 +411,12 @@ void CV_CascadeDetectorTest::readDetector( const FileNode& fn )
if( flag )
flags.push_back( 0 );
else
flags.push_back( CV_HAAR_SCALE_IMAGE );
flags.push_back( CASCADE_SCALE_IMAGE );
}
void CV_CascadeDetectorTest::writeDetector( FileStorage& fs, int di )
{
int sc = flags[di] & CV_HAAR_SCALE_IMAGE ? 0 : 1;
int sc = flags[di] & CASCADE_SCALE_IMAGE ? 0 : 1;
fs << FILENAME << detectorFilenames[di];
fs << C_SCALE_CASCADE << sc;
}
......@@ -439,7 +440,7 @@ int CV_CascadeDetectorTest::detectMultiScale_C( const string& filename,
CvMat c_gray = grayImg;
CvSeq* rs = cvHaarDetectObjects(&c_gray, c_cascade, storage, 1.1, 3, flags[di] );
objects.clear();
for( int i = 0; i < rs->total; i++ )
{
......@@ -494,7 +495,7 @@ CV_HOGDetectorTest::CV_HOGDetectorTest()
void CV_HOGDetectorTest::readDetector( const FileNode& fn )
{
String filename;
if( fn[FILENAME].node->data.seq != 0 )
if( fn[FILENAME].size() != 0 )
fn[FILENAME] >> filename;
detectorFilenames.push_back( filename);
}
......@@ -1085,7 +1086,7 @@ void HOGDescriptorTester::detect(const Mat& img,
}
const double eps = 0.0;
double diff_norm = norm(Mat(actual_weights) - Mat(weights), CV_L2);
double diff_norm = norm(Mat(actual_weights) - Mat(weights), NORM_L2);
if (diff_norm > eps)
{
ts->printf(cvtest::TS::SUMMARY, "Weights for found locations aren't equal.\n"
......@@ -1164,7 +1165,7 @@ void HOGDescriptorTester::compute(const Mat& img, vector<float>& descriptors,
std::vector<float> actual_descriptors;
actual_hog->compute(img, actual_descriptors, winStride, padding, locations);
double diff_norm = cv::norm(Mat(actual_descriptors) - Mat(descriptors), CV_L2);
double diff_norm = cv::norm(Mat(actual_descriptors) - Mat(descriptors), NORM_L2);
const double eps = 0.0;
if (diff_norm > eps)
{
......@@ -1314,7 +1315,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle
const double eps = 0.0;
for (i = 0; i < 2; ++i)
{
double diff_norm = norm(reference_mats[i] - actual_mats[i], CV_L2);
double diff_norm = norm(reference_mats[i] - actual_mats[i], NORM_L2);
if (diff_norm > eps)
{
ts->printf(cvtest::TS::LOG, "%s matrices are not equal\n"
......
......@@ -41,6 +41,7 @@
//M*/
#include "test_precomp.hpp"
#include "opencv2/objdetect/objdetect_c.h"
#include <string>
#ifdef HAVE_TBB
......
......@@ -18,14 +18,14 @@
#include "opencv2/features2d.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/softcascade.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/video/background_segm.hpp"
#include "opencv2/video.hpp"
#include "opencv2/photo.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/photo/photo_c.h"
#include "opencv2/video/tracking_c.h"
#include "opencv2/objdetect/objdetect_c.h"
#include "opencv2/opencv_modules.hpp"
......
......@@ -54,7 +54,7 @@ using namespace cv::superres::detail;
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_GPU()
{
CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform");
CV_Error(Error::StsNotImplemented, "The called functionality is disabled for current build or platform");
return Ptr<SuperResolution>();
}
......
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/objdetect/objdetect_c.h"
#include "opencv2/highgui/highgui_c.h"
#include <ctype.h>
......
......@@ -216,9 +216,9 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
t = (double)cvGetTickCount();
cascade.detectMultiScale( smallImg, faces,
1.1, 2, 0
//|CV_HAAR_FIND_BIGGEST_OBJECT
//|CV_HAAR_DO_ROUGH_SEARCH
|CV_HAAR_SCALE_IMAGE
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
|CASCADE_SCALE_IMAGE
,
Size(30, 30) );
if( tryflip )
......@@ -226,9 +226,9 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
flip(smallImg, smallImg, 1);
cascade.detectMultiScale( smallImg, faces2,
1.1, 2, 0
//|CV_HAAR_FIND_BIGGEST_OBJECT
//|CV_HAAR_DO_ROUGH_SEARCH
|CV_HAAR_SCALE_IMAGE
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
|CASCADE_SCALE_IMAGE
,
Size(30, 30) );
for( vector<Rect>::const_iterator r = faces2.begin(); r != faces2.end(); r++ )
......@@ -263,10 +263,10 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
smallImgROI = smallImg(*r);
nestedCascade.detectMultiScale( smallImgROI, nestedObjects,
1.1, 2, 0
//|CV_HAAR_FIND_BIGGEST_OBJECT
//|CV_HAAR_DO_ROUGH_SEARCH
//|CV_HAAR_DO_CANNY_PRUNING
|CV_HAAR_SCALE_IMAGE
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
//|CASCADE_DO_CANNY_PRUNING
|CASCADE_SCALE_IMAGE
,
Size(30, 30) );
for( vector<Rect>::const_iterator nr = nestedObjects.begin(); nr != nestedObjects.end(); nr++ )
......
#include "opencv2/objdetect.hpp"
#include "opencv2/objdetect/objdetect_c.h"
#include "opencv2/highgui/highgui_c.h"
#include <stdio.h>
......
......@@ -175,9 +175,9 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
cascade.detectMultiScale( smallImg, faces,
1.1, 2, 0
//|CV_HAAR_FIND_BIGGEST_OBJECT
//|CV_HAAR_DO_ROUGH_SEARCH
|CV_HAAR_SCALE_IMAGE
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
|CASCADE_SCALE_IMAGE
,
Size(30, 30) );
if( tryflip )
......@@ -185,9 +185,9 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
flip(smallImg, smallImg, 1);
cascade.detectMultiScale( smallImg, faces2,
1.1, 2, 0
//|CV_HAAR_FIND_BIGGEST_OBJECT
//|CV_HAAR_DO_ROUGH_SEARCH
|CV_HAAR_SCALE_IMAGE
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
|CASCADE_SCALE_IMAGE
,
Size(30, 30) );
for( vector<Rect>::const_iterator r = faces2.begin(); r != faces2.end(); r++ )
......@@ -223,10 +223,10 @@ void detectAndDraw( Mat& img, CascadeClassifier& cascade,
smallImgROI = smallImg(*r);
nestedCascade.detectMultiScale( smallImgROI, nestedObjects,
1.1, 0, 0
//|CV_HAAR_FIND_BIGGEST_OBJECT
//|CV_HAAR_DO_ROUGH_SEARCH
//|CV_HAAR_DO_CANNY_PRUNING
|CV_HAAR_SCALE_IMAGE
//|CASCADE_FIND_BIGGEST_OBJECT
//|CASCADE_DO_ROUGH_SEARCH
//|CASCADE_DO_CANNY_PRUNING
|CASCADE_SCALE_IMAGE
,
Size(30, 30) );
......
......@@ -79,7 +79,7 @@ int main(int , char** )
for (size_t i = 0; i < Faces.size(); i++)
{
rectangle(ReferenceFrame, Faces[i], CV_RGB(0,255,0));
rectangle(ReferenceFrame, Faces[i], Scalar(0,255,0));
}
imshow(WindowName, ReferenceFrame);
......
......@@ -141,7 +141,7 @@ int main(int argc, char** argv)
conf << d.confidence;
cv::rectangle(frame, cv::Rect((int)d.x, (int)d.y, (int)d.w, (int)d.h), cv::Scalar(b, 0, 255 - b, 255), 2);
cv::putText(frame, conf.str() , cv::Point((int)d.x + 10, (int)d.y - 5),1, 1.1, cv::Scalar(25, 133, 255, 0), 1, CV_AA);
cv::putText(frame, conf.str() , cv::Point((int)d.x + 10, (int)d.y - 5),1, 1.1, cv::Scalar(25, 133, 255, 0), 1, cv::LINE_AA);
if (wf)
myfile << d.x << "," << d.y << "," << d.w << "," << d.h << "," << d.confidence << "\n";
......
......@@ -73,7 +73,7 @@ void detectAndDisplay( Mat frame )
cvtColor( frame, frame_gray, COLOR_BGR2GRAY );
equalizeHist( frame_gray, frame_gray );
//-- Detect faces
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
face_cascade.detectMultiScale( frame_gray, faces, 1.1, 2, 0|CASCADE_SCALE_IMAGE, Size(30, 30) );
for( size_t i = 0; i < faces.size(); i++ )
{
......@@ -84,7 +84,7 @@ void detectAndDisplay( Mat frame )
std::vector<Rect> eyes;
//-- In each face, detect eyes
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CV_HAAR_SCALE_IMAGE, Size(30, 30) );
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
for( size_t j = 0; j < eyes.size(); j++ )
{
......
......@@ -82,7 +82,7 @@ void detectAndDisplay( Mat frame )
std::vector<Rect> eyes;
//-- In each face, detect eyes
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CV_HAAR_SCALE_IMAGE, Size(30, 30) );
eyes_cascade.detectMultiScale( faceROI, eyes, 1.1, 2, 0 |CASCADE_SCALE_IMAGE, Size(30, 30) );
if( eyes.size() == 2)
{
//-- Draw the face
......
......@@ -228,8 +228,8 @@ int main(int argc, const char *argv[])
Size minSize = cascade_gpu.getClassifierSize();
cascade_cpu.detectMultiScale(resized_cpu, facesBuf_cpu, 1.2,
(filterRects || findLargestObject) ? 4 : 0,
(findLargestObject ? CV_HAAR_FIND_BIGGEST_OBJECT : 0)
| CV_HAAR_SCALE_IMAGE,
(findLargestObject ? CASCADE_FIND_BIGGEST_OBJECT : 0)
| CASCADE_SCALE_IMAGE,
minSize);
detections_num = (int)facesBuf_cpu.size();
}
......
......@@ -326,7 +326,7 @@ void App::run()
for (size_t i = 0; i < found.size(); i++)
{
Rect r = found[i];
rectangle(img_to_show, r.tl(), r.br(), CV_RGB(0, 255, 0), 3);
rectangle(img_to_show, r.tl(), r.br(), Scalar(0, 255, 0), 3);
}
if (use_gpu)
......
......@@ -51,7 +51,7 @@ int main(int argc, const char* argv[])
for (size_t i = 0; i < lines_cpu.size(); ++i)
{
Vec4i l = lines_cpu[i];
line(dst_cpu, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, CV_AA);
line(dst_cpu, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, LINE_AA);
}
GpuMat d_src(mask);
......@@ -77,7 +77,7 @@ int main(int argc, const char* argv[])
for (size_t i = 0; i < lines_gpu.size(); ++i)
{
Vec4i l = lines_gpu[i];
line(dst_gpu, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, CV_AA);
line(dst_gpu, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0, 0, 255), 3, LINE_AA);
}
imshow("source", src);
......
......@@ -144,7 +144,7 @@ string abspath(const string& relpath)
}
static int CV_CDECL cvErrorCallback(int /*status*/, const char* /*func_name*/,
static int cvErrorCallback(int /*status*/, const char* /*func_name*/,
const char* err_msg, const char* /*file_name*/,
int /*line*/, void* /*userdata*/)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment