特定のコーディングを理解するのに問題があります。これがばかげている場合は申し訳ありませんが、ウェブカメラからビデオをキャプチャするコードを持っています。フレームから 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);