我使用ORB功能检测器使用此代码查找两个图像之间的匹配:
FeatureDetector detector = FeatureDetector.create(FeatureDetector.ORB);
DescriptorExtractor descriptor = DescriptorExtractor.create(DescriptorExtractor.ORB);;
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
// First photo
Imgproc.cvtColor(img1, img1, Imgproc.COLOR_RGB2GRAY);
Mat descriptors1 = new Mat();
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
detector.detect(img1, keypoints1);
descriptor.compute(img1, keypoints1, descriptors1);
// Second photo
Imgproc.cvtColor(img2, img2, Imgproc.COLOR_RGB2GRAY);
Mat descriptors2 = new Mat();
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
detector.detect(img2, keypoints2);
descriptor.compute(img2, keypoints2, descriptors2);
// Matching
MatOfDMatch matches = new MatOfDMatch();
MatOfDMatch filteredMatches = new MatOfDMatch();
matcher.match(descriptors1, descriptors2, matches);
// Linking
Scalar RED = new Scalar(255,0,0);
Scalar GREEN = …Run Code Online (Sandbox Code Playgroud) 我在网站上看到了一些类似的问题,但没有一个真正帮助过我.
我有一个函数,当单击一个按钮时,它会在窗体上绘制几行,这些按钮的形状会根据用户在某些文本框中输入的值而变化.
我的问题是,当我最小化形式时,线条消失,我明白这可以通过使用OnPaint事件来解决,但我真的不明白如何.
任何人都可以给我一个简单的例子,使用函数在按下按钮时使用OnPaint事件绘制一些东西吗?
我怎样才能得到一个绝对值,告诉我模板在它最匹配的地方匹配了多少?我知道 minMaxLoc() ,但这只能告诉我最大的值是多少,但我不知道 MAXIMUM 值是多少,因此我可以了解它的匹配程度。
我见过有人说你可以使用归一化得到一个百分比,但这并没有真正帮助我,因为最大的值总是 100%。我错过了什么吗?
我试图将用户提交的PNG图像转换为JPEG,但是当我尝试保存图像时,我得到了
<type 'exceptions.IndexError'>: string index out of range
Run Code Online (Sandbox Code Playgroud)
我正在使用CGI在Apache中运行python脚本.当我在控制台中运行脚本时,它可以正常工作.
这是代码.
if imghdr.what(filePath) == 'png':
p = Image.open(filePath)
p.save('../files/outfile.jpg', "JPEG")
filePath = "../files/outfile.jpg"
Run Code Online (Sandbox Code Playgroud)
p.save()行发生错误.我认为这是一个权限问题,但我连上的文件/目录给予777个权限,它仍然是行不通的.
编辑 这是save()调用之后的内容.
/usr/lib/python2.7/dist-packages/PIL/Image.py in save(self=<PIL.PngImagePlugin.PngImageFile image mode=RGB size=512x512>, fp='../files/outfile.jpg', format='JPEG', **params={})
1434
1435 # may mutate self!
=> 1436 self.load()
1437
1438 self.encoderinfo = params
self = <PIL.PngImagePlugin.PngImageFile image mode=RGB size=512x512>, self.load = <bound method PngImageFile.load of <PIL.PngImagePlugin.PngImageFile image mode=RGB size=512x512>>
/usr/lib/python2.7/dist-packages/PIL/ImageFile.py in load(self=<PIL.PngImagePlugin.PngImageFile image mode=RGB size=512x512>)
204 break
205 else:
=> 206 raise IndexError(ie)
207
208 …Run Code Online (Sandbox Code Playgroud)