【发布时间】:2013-03-13 11:55:33
【问题描述】:
如果理解某些编码我会遇到麻烦我很抱歉如果这很愚蠢但我有一个代码可以从我的网络摄像头捕获视频我想从帧中获取 RGB 值如果这是不可能的将帧保存为图片,然后从中获取值?
const char window_name[]="网络摄像头";
int main(int argc, char* argv[]) {
/* attempt to capture from any connected device */
CvCapture *capture=cvCaptureFromCAM(CV_CAP_ANY);
if(!capture)
{
printf("Failed to initialise webcam\n");
return -1;
}
/* create the output window */
cvNamedWindow(window_name, CV_WINDOW_NORMAL);
do
{
/* attempt to grab a frame */
IplImage *frame=cvQueryFrame(capture);
if(!frame)
{
printf("Failed to get frame\n");
break;
}
COLORREF myColAbsolute = GetPixel(frame, 10,10);//error in saying frame is not compatible with HDC.
cout << "Red - " << (int)GetRValue(myColAbsolute) << endl;
cout << "Green - " << (int)GetGValue(myColAbsolute) << endl;
cout << "Blue - " << (int)GetBValue(myColAbsolute) << endl;
/* show the frame */
cvShowImage(window_name, frame);
【问题讨论】:
-
我认为可能缺少一些代码,因为循环没有结束(我希望有一个右括号和一个 while 条件)。