亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Using OpenCV with Qt

系統 1851 0

The IplImage and Qt

In order to take advantage of the 500 algorithms offered by OpenCV, Qt applications have to manage ? iplImages . Therefore, converting ? QImage to/from ? iplImage ? is very important.

Converting QImage to iplImage

This snippet will convert ? QImages ? into ? iplImage ? with depth 8 and 3 channels. ? QImage ? can store data in several formats. This code accepts just 24-bit ? QImage::Format_RGB888 ? and the QImage::Format_RGB32 . Apha values in the 32-bit format will be removed during the conversion.

    static IplImage* qImage2IplImage(const QImage& qImage)

  {

    int width = qImage.width();

    int height = qImage.height();

 

    // Creates a iplImage with 3 channels

    IplImage *img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);

    char * imgBuffer = img->imageData;

 

    //Remove alpha channel

    int jump = (qImage.hasAlphaChannel()) ? 4 : 3;

 

    for (int y=0;y<img->height;y++){

      QByteArray a((const char*)qImage.scanLine(y), qImage.bytesPerLine());

      for (int i=0; i<a.size(); i+=jump){

          //Swap from RGB to BGR

          imgBuffer[2] = a[i];

          imgBuffer[1] = a[i+1];

          imgBuffer[0] = a[i+2];

          imgBuffer+=3;

      }

  }

 

  return img;

  }
  

Converting iplImage to QImage

This snippet will convert a ? iplImage ? with depth 8 and 1 or 3 channels into a 8/24-bit ? QImage .

Note: ?This code won't work for images with different depth and number of channels.
    static QImage IplImage2QImage(const IplImage *iplImage)

{

    int height = iplImage->height;

    int width = iplImage->width;

 

    if  (iplImage->depth == IPL_DEPTH_8U && iplImage->nChannels == 3)

    {

      const uchar *qImageBuffer = (const uchar*)iplImage->imageData;

      QImage img(qImageBuffer, width, height, QImage::Format_RGB888);

      return img.rgbSwapped();

    } else if  (iplImage->depth == IPL_DEPTH_8U && iplImage->nChannels == 1){

	const uchar *qImageBuffer = (const uchar*)iplImage->imageData;

	QImage img(qImageBuffer, width, height, QImage::Format_Indexed8);

 

	QVector<QRgb> colorTable;

	for (int i = 0; i < 256; i++){

	    colorTable.push_back(qRgb(i, i, i));

	}

	img.setColorTable(colorTable);

	return img;

    }else{

      qWarning() << "Image cannot be converted.";

      return QImage();

    }

}
  

?

http://www.developer.nokia.com/Community/Wiki/Using_OpenCV_with_Qt

?

Using OpenCV with Qt


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 另类色视频 | 五月天激情视频在线观看 | 国产精品深夜福利免费观看 | 国产第一色 | 亚洲欧美国产另类 | 欧美成人免费观看国产 | 日本在线不卡视频 | 国产一区二区三区在线观看免费 | 亚洲欧美久久精品 | 亚洲欧美不卡中文字幕 | 四虎影院www| 成人亚洲性情网站www在线观看 | 国产女人水多毛片18 | 国产一区a | 精品日韩在线视频 | 亚洲一区小说区中文字幕 | a毛片成人免费全部播放 | 特黄特级毛片免费视 | 国产欧美亚洲精品综合在线 | 999热这里全都是精品 | 五月伊人网 | 亚洲欧美日韩在线一区二区三区 | 亚洲欧洲尹人香蕉综合 | 中国一级特黄大片毛片 | 亚洲国产精品悠悠久久琪琪 | 欧美视频一区二区三区在线观看 | 一级一级毛片免费播放 | 国产欧美亚洲精品第二区首页 | 日本一级毛片无遮挡 | 在线视频免费国产成人 | 国产精品久久久久9999 | 香蕉爱爱网| 高清人人天天夜夜曰狠狠狠狠 | 国产亚洲人成a在线v网站 | 老黄网站| 香蕉大黄香蕉在线观看 | 在线精品中文字幕福利视频 | 国产精品夜色一区二区三区 | 久久香蕉国产 | 99热色| 久久免费国产精品一区二区 |