我正在尝试将 Simple Blog Detector 与 Swift 和 OpenCV Objective C++ 包装器以及适用于 iOS 的 OpenCV 3.1.0 一起使用。但是,我遇到了几个错误。我不理解它们,因为它们暗示我正在使用 stitching.hpp,但我不是。有什么建议么?我不明白为什么它会调用 stitching.hpp 搅拌器和曝光补偿。
错误是:命名空间“cv::detail”stitching.hpp 中没有名为“ExposureCompensator”的成员和:命名空间“cv::detail”stitching.hpp 中没有名为“Blender”的成员
标题被添加到开头,因为我最初从宏中的预期标识符“NO”中得到解析问题。通过添加这些 header ,我按照源文件中的建议删除了解析问题,但这导致了如上所述的新错误。
#ifndef OPENCV_STITCHING_BLENDERS_HPP
#define OPENCV_STITCHING_BLENDERS_HPP
#if defined(NO)
#warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
#endif
#ifndef OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP
#define OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP
#if defined(NO)
#warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
#endif
#import "OpenWrapper.h"
#import <opencv2/opencv.hpp>
#import <opencv2/core/core.hpp>
#import <opencv2/imgcodecs/ios.h>
#import <opencv2/imgproc.hpp>
using namespace std;
using namespace cv;
@implementation OpenWrapper
+(UIImage *) makeGrayscale:(UIImage *)myImage{
// Convert UIImage to Mat
Mat imageMat;
UIImageToMat(myImage, imageMat);
// Convert from color to grayscale image
Mat graymat;
cvtColor(imageMat, graymat, CV_BGR2GRAY);
// Set up Simple Blob Parameters
SimpleBlobDetector::Params params;
params.minThreshold = 10;
params.maxThreshold = 200;
params.filterByArea = true;
params.minArea = 1500;
params.filterByCircularity = true;
params.minConvexity = 0.87;
params.filterByInertia = true;
params.minInertiaRatio = 0.01;
// Creat dectector with keypoints
vector<KeyPoint> keypoints;
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
detector->detect(graymat, keypoints);
// Mat im_with_keypoints;
Mat im_with_keypoints;
drawKeypoints(graymat, keypoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
// Show blobs
imshow("keypoints", im_with_keypoints );
waitKey(0);
// Output results as UIIMage
return MatToUIImage(graymat);
}
#endif
#endif
@end
最佳答案
简单的初学者错误。 OpenCV 文档明确指出将所有 OpenCV 语句放在任何 Apple 代码之前,以防止出现枚举错误。意思是确保将 opencv import 语句放在 Obj C++ import header 语句之前。
关于c++ - 使用简单 Blob 检测器时,命名空间 'Blender' stitching.hpp 中没有名为 'cv::detail' 的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40050326/