【问题标题】:alpha channel webcam capture opencv c++alpha通道网络摄像头捕获opencv c ++
【发布时间】:2015-01-10 14:23:33
【问题描述】:

我在 usb-port 上阅读了一个罗技 c200 网络摄像头,并在 c++ 中使用 opencv 编写了这段代码:

Mat result;
IplImage* frame;
int hell=0;
int dunkel=0;
CvCapture* capture;
capture = 0;
capture = cvCaptureFromCAM( CV_CAP_ANY );
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 240);

frame = cvQueryFrame( capture );

if( !frame ) break;
result = frame;
flip(result , result ,-1);

cvReleaseCapture( &capture );

for(int i = 0; i < 240; ++i){
    for(int j = 0; j < 320; ++j){ 

    if((result.at<Vec3b>(i,j)[1] > 230) && (result.at<Vec3b>(i,j)[0] > 230))
        { hell++;}
    else
        {dunkel++;}
    }
}

如何获取 alpha 通道,在本例中为 OpenCV 中 Mat-Matrix 中一个元素的 [4] 第四个元素?

感谢您的帮助

【问题讨论】:

  • (请不要把反对票看得太个人化,但是你的代码对于新手来说是一个坏例子,并且会留在 SO永远

标签: c++ opencv webcam alpha channel


【解决方案1】:

来自网络摄像头的图像中没有 Alpha 通道。

另外,请使用opencv的c++ api,老c是死路一条。

【讨论】:

    【解决方案2】:

    是否有可能从网络摄像头读取 Alpha 通道? 像 hsv-color 模型:

    http://en.wikipedia.org/wiki/HSL_and_HSV

    是色调(法布顿)

    【讨论】:

      猜你喜欢
      • 2015-08-18
      • 1970-01-01
      • 1970-01-01
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-18
      相关资源
      最近更新 更多