我正在使用Mac OSX 10.9在OpenCV 2.4.9中编写项目。我一直在得到这个奇怪的错误,标题中详细说明,似乎无法弄明白。任何帮助表示赞赏,谢谢! AppDelegate.m文件 -
- (IBAction)manual:(id)sender {
cv::VideoCapture cap(0);
if ( !cap.isOpened()) {
std::cout << "Cannot open the web cam" << std::endl;
}
cv::namedWindow("Control", CV_WINDOW_AUTOSIZE);
cv::namedWindow("Manual Calibration", CV_WINDOW_AUTOSIZE);
self.LH = 0;
self.HH = 179;
self.LS = 0;
self.HS = 255;
self.LV = 0;
self.HV = 255;
//int counter = 0;
//Error is here
cv::createTrackbar("Low Hue- ", "Control", self.LH, 179);
cv::createTrackbar("High Hue- ", "Control", self.HH, 179);
cv::createTrackbar("Low Saturation- ", "Control", self.LS, 255);
cv::createTrackbar("High Saturation- ", "Control", self.HS, 255);
cv::createTrackbar("Low Value- ", "Control", self.LV, 255);
cv::createTrackbar("High Value- ", "Control", self.HV, 255);
while (true){
cv::Mat testInitial;
cap.read(testInitial);
cv::Mat testHSV;
cv::Mat test;
cvtColor(testInitial, testHSV, CV_BGR2HSV);
cv::inRange(testHSV,cv::Scalar((self.LH), (self.LS), (self.LV)),cv::Scalar((self.HH), (self.HS), (self.HV)),test);
cv::imshow("Test", test);
cv::waitKey(10);
}
}
AppDelegate.h文件 -
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate> {
IBOutlet NSMenu *statusMenu;
NSStatusItem *statusItem;
NSImage *statusImage;
NSImage *statusHighlightImage;
}
//Action
- (IBAction)start:(id)sender;
- (IBAction)manual:(id)sender;
- (IBAction)automatic:(id)sender;
@property (nonatomic, assign) int LH;
@property (nonatomic, assign) int HH;
@property (nonatomic, assign) int LS;
@property (nonatomic, assign) int HS;
@property (nonatomic, assign) int LV;
@property (nonatomic, assign) int HV;
@end
答案 0 :(得分:1)
你应该将整数变量的地址传递给createTrackBar。
int hue = 17; // start value
cv::createTrackbar("Low Hue- ", "Control", &hue, 179);