这似乎应该非常简单,但由于某种原因,我的线没有居中 - 它比应该的更靠左。
这是我的代码:
static const int width = 240;
static const int height = 320;
VideoCapture cap(0);
cap.set(CV_CAP_PROP_FRAME_WIDTH, width);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, height);
//Set points for center line
CvPoint mid_bottom, mid_top;
mid_bottom.x = width/2;
mid_bottom.y = 0;
mid_top.x = width/2;
mid_top.y = height;
//for purposes not related to this issue, I have to use IplImages instead of Mats
Mat frame; //(edit - forgot this declaration before, sorry!)
cap >> frame;
IplImage frame_ipl = frame;
//drawing the line
cvLine(&frame_ipl, mid_bottom, mid_top, RED, 2);
关于为什么会出错的任何想法?