OpenCV Android - error on match template -


i've seen questions here related error such this , this , know can't execute imgproc.matchtemplate() method if image , template don't have same datatype. i'm still confused on how know type of mat i'm using.

below code adapted example here:

for (int = 0; < 24; i++) {     arrdraw[i] = getresources().getidentifier("let" + i, "drawable", getpackagename()); }  mat mimage = input.submat(bigrect); (int = 0; < 24; i++) {     mat mtemplate = utils.loadresource(this, arrdraw[i], highgui.cv_load_image_color);     mat mresult = new mat(mimage.rows(), mimage.cols(), cvtype.cv_32fc1);     imgproc.matchtemplate(mimage, mtemplate, mresult, match_method);     core.normalize(mresult, mresult, 0, 1, core.norm_minmax, -1, new mat());     ... // further process } 

so i'm trying take mimage submat of inputframe , match template process 24 other pictures , decide has best value (either lowest or highest). yet error shows this.

opencv error: assertion failed ((img.depth() == cv_8u || img.depth() == cv_32f) && img.type() == templ.type()) in void cv::matchtemplate(cv::inputarray, cv::inputarray, cv::outputarray, int), file /home/reports/ci/slave_desktop/50-sdk/opencv/modules/imgproc/src/templmatch.cpp, line 249 

i tried initialize mimage , mtemplate first same type still no luck. advice? before.

the error telling image , template have different types.

assertion failed  ... img.type() == templ.type() .... 

i'd willing bet (a small amount) mtemplate cv_8uc3 bgr ordered.

from code posted, it's not possible tell mimage's type though if it's extracted camera frame, , if did :

public mat oncameraframe(cvcameraviewframe inputframe) {      mat inputframe = inputframe.rgba();      .... } 

then it's cv_8uc4 bgra ordered. not same type.

also, i'm not sure behaviour of submat() 1 3d or 4d input matrix, think it's designed operate on 2d matrices may find returns either 2d matrix (cv_8uc2) or undefined weirdness.

i'd suggest try dumping type() , depth() or both image , template before matchtemplate( ... ) call.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -