Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Procedure cv_LoadImage(ImFile:PChar; var Mat: Pointer; var Width,Height:Int32);
- void loadImage(char* imfile, Mat** cvImage, int &Width, int &Height)
- {
- Mat* res = new Mat();
- *res = imread(imfile);
- if (res->empty())
- {
- cout << "Cannot load image!" << endl;
- cvImage = NULL;
- return;
- }
- Width = res->cols;
- Height = res->rows;
- *cvImage = res;
- }
- // Procedure cv_FreeImage(var Mat: Pointer);
- void freeImage(Mat** cvImage) {
- Mat* res = *cvImage;
- res->release();
- delete *cvImage;
- *cvImage = NULL;
- }
- // Function cv_MatchTemplate(var Sub,Img:Pointer; MatchMethod: Int32; var Mat: Pointer): Pointer;
- float* matchTemplate(Mat* &templ, Mat* &im, int matchMethod, Mat** result)
- {
- if ((matchMethod < 0) || (matchMethod > 5))
- {
- cout << "Undefined matchMethod! Should be in range of 0-5" << endl;
- return NULL;
- }
- if ((im->type() != templ->type()) || (im->depth() != templ->depth()))
- {
- cout << "[Error]: " << endl;
- cout << "\t-> type:\t" << templ->type() << ", " << im->type() << endl;
- cout << "\t-> depth:\t" << templ->depth() << ", " << im->depth() << endl;
- return NULL;
- }
- Mat* res = new Mat();
- int result_cols = im->cols - templ->cols + 1;
- int result_rows = im->rows - templ->rows + 1;
- res->create( result_cols, result_rows, CV_32FC1 );
- //cout << "Processing..." << endl;
- matchTemplate( *im, *templ, *res, matchMethod );
- normalize( *res, *res, 0, 1, NORM_MINMAX, -1, Mat() );
- *result = res;
- return (float*)res->data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement