如何在小图像上使用Opencv FeatureDetecter
发布时间:2020-12-15 03:05:18 所属栏目:Java 来源:网络整理
导读:我在 Java中使用Opencv 3,我试图在其他图像上找到小图像(如25×25像素).但FeatureDetector检测(0,0)大小Mat在小图像上. Mat smallImage = ... FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB); DescriptorExtractor descriptor = D
我在
Java中使用Opencv 3,我试图在其他图像上找到小图像(如25×25像素).但FeatureDetector检测(0,0)大小Mat在小图像上.
Mat smallImage = ... FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB); DescriptorExtractor descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB); DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING); Mat descriptorsSmall = new Mat(); MatOfKeyPoint keyPointsSmall = new MatOfKeyPoint(); detector.detect(smallImage,keyPointsSmall); descriptor.compute(smallImage,keyPointsSmall,descriptorsSmall); 在这里,我得到keyPointsSmall和descriptorsSmall大小为零,并确保检测不起作用. 但是,如果我在150×150像素的较大图像上尝试此功能,那就可以了. 我在这里添加样品. 并且让它说我们有P字母的模板,所以我们需要在源图像上检测这个P. 好吧,将图像缩放到更高的分辨率对我来说不起作用.那将耗费时间和资源. 除OpenCv之外的其他解决方案对我来说是不可接受的. (例如使用Tesseract) 解决方法
用于文本识别的关键点检测不是最佳解决方案,因为您将获得许多看起来相似的功能,并且如果模板非常小,则滑动窗口将不会产生足够的检测到的功能.
幸运的是,OpenCV 3在contrib存储库中包含一个文本检测/识别模块:link,其中一个示例取自here,还有许多其他模块可以找到here: /* * cropped_word_recognition.cpp * * A demo program of text recognition in a given cropped word. * Shows the use of the OCRBeamSearchDecoder class API using the provided default classifier. * * Created on: Jul 9,2015 * Author: Lluis Gomez i Bigorda <lgomez AT cvc.uab.es> */ #include "opencv2/text.hpp" #include "opencv2/core/utility.hpp" #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp" #include <iostream> using namespace std; using namespace cv; using namespace cv::text; int main(int argc,char* argv[]) { cout << endl << argv[0] << endl << endl; cout << "A demo program of Scene Text Character Recognition: " << endl; cout << "Shows the use of the OCRBeamSearchDecoder::ClassifierCallback class using the Single Layer CNN character classifier described in:" << endl; cout << "Coates,Adam,et al. "Text detection and character recognition in scene images with unsupervised feature learning." ICDAR 2011." << endl << endl; Mat image; if(argc>1) image = imread(argv[1]); else { cout << " Usage: " << argv[0] << " <input_image>" << endl; cout << " the input image must contain a single character (e.g. scenetext_char01.jpg)." << endl << endl; return(0); } string vocabulary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // must have the same order as the clasifier output classes Ptr<OCRHMMDecoder::ClassifierCallback> ocr = loadOCRHMMClassifierCNN("OCRBeamSearch_CNN_model_data.xml.gz"); double t_r = (double)getTickCount(); vector<int> out_classes; vector<double> out_confidences; ocr->eval(image,out_classes,out_confidences); cout << "OCR output = "" << vocabulary[out_classes[0]] << "" with confidence " << out_confidences[0] << ". Evaluated in " << ((double)getTickCount() - t_r)*1000/getTickFrequency() << " ms." << endl << endl; return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- SpringBoot使用自定义注解实现权限拦截的示例
- java – 为什么在这种情况下我们需要Publish和RefCount Rx
- Java:扩展Object类
- java – 尝试使用tomcat-maven-plugin部署maven项目时出现错
- java – allure2 listener输出控制台中的步骤
- java.io.FileDescriptor#sync()是否特定于单个FileDescript
- Java 3D游戏引擎?
- java – Kafka – 关闭(kafka.server.KafkaServer),启动Kaf
- Java-Flink-多个源的集成测试
- java – 应该为特定的Web应用程序选择哪些框架?