java类方法源码:
public void tezhengdian(String img1,String img2){
Mat src_base = Imgcodecs.imread(img1);
Mat src_test = Imgcodecs.imread(img2);
Mat gray_base = new Mat();
Mat gray_test = new Mat();
Imgproc.cvtColor(src_base, gray_base, Imgproc.COLOR_RGB2GRAY);
Imgproc.cvtColor(src_test, gray_test, Imgproc.COLOR_RGB2GRAY);
FeatureDetector featureDetector = FeatureDetector.create(FeatureDetector.ORB);
DescriptorExtractor descriptorExtractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
MatOfKeyPoint keyPoint1 = new MatOfKeyPoint(), keyPoint2 = new MatOfKeyPoint();
Mat descriptorMat1 = new Mat(), descriptorMat2 = new Mat();
featureDetector.detect(gray_base, keyPoint1);//这里是报错位置
featureDetector.detect(gray_test, keyPoint2);
descriptorExtractor.compute(gray_base, keyPoint1, descriptorMat1);
descriptorExtractor.compute(gray_test, keyPoint2, descriptorMat2);
......
之后是数值计算
......
}
郁闷的是这个方法连续调用多次之后才会报错,差不多100次以内的调用不会报错。
报错信息:
OpenCV Error: Assertion failed (clEnqueueWriteBuffer(q, (cl_mem)u->handle, CL_TRUE, dstrawofs, total, alignedPtr.getAlignedPtr(), 0, 0, 0) >= 0) in cv::ocl::OpenCLAllocator::upload, file C:\builds\master_PackSlaveAddon-win64-vc12-static\opencv\modules\core\src\ocl.cpp, line 5114