【发布时间】:2020-12-13 10:59:13
【问题描述】:
我在 Objective-C++ 中有一个 iOS OpenCV 包装器,如下所示:
// CVImage.mm
@interface CVImage()
@property std::vector<std::vector<cv::Point>> contours;
@end
@implementation CVImage
...
- (void) findContours
{
// Find and store contours with cv::findContours
}
// Resize method
- (void) resizeTo:(NSInteger)count
{
// Stuff that ensures count is less than self.contours.size()
...
self.contours.resize(count);
}
...
@end
但contours 向量不会调整大小。它们在屏幕上绘制得很好,但如果我尝试调整大小或对其进行排序,代码会引发错误。
在本地测试 std::vector<std::vector<cv::Point>> 变量上执行调整大小有效,但不是我的实例成员变量。
我在CVImage() 类别中的初始化是否错误?还是 OpenCV 做了什么奇怪的事情?
【问题讨论】:
标签: c++ ios objective-c opencv vector