目前我正在使用OpenCV处理来自AVCaptureSession的图像。该应用程序现在采取这些图像,并在blob上绘制cv :: Circles。跟踪工作正在进行,但是当我绘制圆圈时,它会显示为灰色,扭曲的圆圈,应该是绿色。是否OpenCV绘图功能无法与iOS应用程序一起使用?或者我有什么办法可以解决它?
任何帮助都将不胜感激。
cv :: Circle位于黑色圆圈的外面。
这是我将CMSampleBuffer转换为cv :: Mat:
的地方enter code here CVImageBufferRef pixelBuff = CMSampleBufferGetImageBuffer(sampleBuffer);
cv::Mat cvMat;
CVPixelBufferLockBaseAddress(pixelBuff, 0);
int bufferWidth = CVPixelBufferGetWidth(pixelBuff);
int bufferHeight = CVPixelBufferGetHeight(pixelBuff);
unsigned char *pixel = (unsigned char *)CVPixelBufferGetBaseAddress(pixelBuff);
cvMat = cv::Mat(bufferHeight, bufferWidth, CV_8UC4, pixel);
cv::Mat grayMat;
cv::cvtColor(cvMat, grayMat, CV_BGR2GRAY);
CVPixelBufferUnlockBaseAddress(pixelBuff, 0);
这是cv :: Circle命令:
if (keypoints.size() > 0) {
cv::Point p(keypoints[0].pt.x, keypoints[0].pt.y);
printf("x: %f, y: %f\n",keypoints[0].pt.x, keypoints[0].pt.y);
cv::circle(cvMat, p, keypoints[0].size/2, cv::Scalar(0,255,0), 2, 8, 0);
}
关键点是已检测到的斑点矢量。