这是演示者类的代码,我在其中调用api,并使用接口获取响应并将响应发送给活动类(视图):
int main()
{
image = imread("sample.jpg", 1);
cv::resize(image, source, Size(), 0.5, 0.5, INTER_LINEAR);
// Make a dummy image, will be useful to clear the drawing
Mat dummy = source.clone();
namedWindow("Window",WINDOW_AUTOSIZE);
// highgui function called when mouse events occur
setMouseCallback("Window", drawCircle);
int k = 0;
// loop until escape character is pressed
while (k != 27)
{
imshow("Window", source);
putText(source, "Choose center, and drag, Press ESC to exit and c to clear", Point(10, 30), FONT_HERSHEY_SIMPLEX, 0.7, Scalar(255, 255, 255), 2);
k = waitKey(20) & 0xFF;
if (k == 99)
// Another way of cloning
dummy.copyTo(source);
}
return 0;
}