使用CvKNearest :: find_nearest时出现OpenCV错误

时间:2017-05-06 09:17:17

标签: c++ opencv image-processing

  

错误C2664:'float CvKNearest :: find_nearest(const cv :: Mat   &,int,cv :: Mat&,cv :: Mat&,cv :: Mat&)const':不能转换参数   1从'cv :: Mat'到'const CvMat *'

                CV::Mat matROI = img_thr(validContoursWithData[i].boundingRect);           // get ROI image of bounding rect

                cv::Mat matROIResized;
                cv::resize(matROI, matROIResized, cv::Size(RESIZED_IMAGE_WIDTH, RESIZED_IMAGE_HEIGHT));     // resize image, this will be more consistent for recognition and storage

                cv::Mat matROIFloat;
                matROIResized.convertTo(matROIFloat, CV_32FC1);             // convert Mat to float, necessary for call to find_nearest
                //cvConvertScale(matROIResized, matROIFloat, 1, 0);
                cv::Mat matROIFlattenedFloat = matROIFloat.reshape(1, 1);

                cv::Mat matCurrentChar(0, 0, CV_32F);

                kNearest.find_nearest(matROIFlattenedFloat, 1, matCurrentChar);     // finally we can call find_nearest !!!

                float fltCurrentChar = (float)matCurrentChar.at<float>(0, 0);

                strFinalString = strFinalString + char(int(fltCurrentChar));        // append current char to full string
            }

            std::cout << "\n\n" << "numbers read = " << strFinalString << "\n\n";       // show the full string

            cv::imshow("matTestingNumbers", imgs[a]);     // show input image with green boxes drawn around found digits

0 个答案:

没有答案