欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

Using OpenCV with Qt

系統 1921 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條評論
主站蜘蛛池模板: 欧美 国产 综合 | 国产日韩亚洲不卡高清在线观看 | 亚洲一卡二卡在线 | 亚洲不卡在线 | 美女扒开内裤让男人桶 | 亚洲欧美日韩中文不卡 | 一区二区免费视频观看 | 亚洲综合国产一区二区三区 | 欧美一区二区三区中文字幕 | 国产三级做爰在线观看视频 | 欧美一级片毛片 | 国产精品中文字幕在线 | 日韩精品在线视频 | 国产在线观看福利片 | 国产小视频在线 | 成人网在线播放 | 亚洲午夜久久久久久尤物 | 欧美日韩不卡 | 欧美图片激情小说 | 成人国产一区二区三区 | 在线视频h| 91久久极品 | 成人性爱视频在线观看 | 黄色资源视频 | 久久韩剧网 | 91久久精品久久国产性色也91 | 免费视频大片在线观看 | 亚洲精品欧美一区二区三区 | 精品在线不卡 | 邪不压正免费观看完整高清视频 | 99久久久久国产精品免费 | 日韩日b视频 | 一区二区三区四区在线观看视频 | 91茄子国产线观看免费 | 亚洲国产精品人人爽夜夜爽 | 一级淫片免费 | 韩国一级免费视频 | 一区二区三区在线播放 | 国产人A片777777久久 | 亚洲人成在线精品 | 久久久久久免费免费 |