#define FILTER_OUT_OF_BOUNDARIES -7
#define FFT_OK 2
#define FFT_ERROR -8
+#define LSVM_PARSER_FILE_NOT_FOUND -9
#endif
int* kPartFilters = 0;\r
float* b = 0;\r
float scoreThreshold = 0.f;\r
+ int err_code = 0;\r
\r
- loadModel(filename, &filters, &kFilters, &kComponents, &kPartFilters, &b, &scoreThreshold);\r
+ err_code = loadModel(filename, &filters, &kFilters, &kComponents, &kPartFilters, &b, &scoreThreshold);\r
+ if (err_code != LATENT_SVM_OK) return 0;\r
\r
detector = (CvLatentSvmDetector*)malloc(sizeof(CvLatentSvmDetector));\r
detector->filters = filters;\r
#include <stdio.h>\r
#include "string.h"\r
#include "_lsvmparser.h"\r
+#include "_lsvm_error.h"\r
\r
int isMODEL (char *str){\r
char stag [] = "<Model>";\r
\r
xmlf = fopen(filename, "rb");\r
if(xmlf == NULL){\r
- return -1;\r
+ return LSVM_PARSER_FILE_NOT_FOUND;\r
}\r
\r
i = 0;\r
}\r
} \r
}\r
- return 0;\r
+ return LATENT_SVM_OK;\r
}\r
\r
int loadModel(\r
//printf("start_parse\n\n");\r
\r
err = LSVMparser(modelPath, filters, &last, &max, &comp, b, &count, &score);\r
- if(err != 0){\r
- return -1;\r
+ if(err != LATENT_SVM_OK){\r
+ return err;\r
}\r
(*kFilters) = last + 1;\r
(*kComponents) = count;\r
using namespace cv;\r
\r
const char* model_filename = "cat.xml";\r
-const char* image_filename = "000028.jpg";\r
+const char* image_filename = "cat.jpg";\r
\r
void detect_and_draw_objects( IplImage* image, CvLatentSvmDetector* detector)\r
{\r
\r
int main(int argc, char* argv[])\r
{\r
+ if (argc > 2)\r
+ {\r
+ image_filename = argv[1];\r
+ model_filename = argv[2];\r
+ }\r
IplImage* image = cvLoadImage(image_filename);\r
+ if (!image)\r
+ {\r
+ printf( "Unable to load the image\n"
+ "Pass it as the first parameter: latentsvmdetect <path to cat.jpg> <path to cat.xml>\n" );\r
+ return -1;\r
+ }\r
CvLatentSvmDetector* detector = cvLoadLatentSvmDetector(model_filename);\r
+ if (!detector)\r
+ {\r
+ printf( "Unable to load the model\n"
+ "Pass it as the second parameter: latentsvmdetect <path to cat.jpg> <path to cat.xml>\n" );\r
+ cvReleaseImage( &image );\r
+ return -1;\r
+ }\r
detect_and_draw_objects( image, detector );\r
cvNamedWindow( "test", 0 );\r
cvShowImage( "test", image );\r