qimage

Applying overlays to image with varying transparency

∥☆過路亽.° 提交于 2019-11-26 17:24:35
问题 I have got a RGB image (224x224x3) and an overlay (224x224). Now I want to apply my overlay as red pixels on my RGB image, which I make therefore to grayscale. The overlay range from 0 to 255. Higher values should make a stronger red. I tried to use Stefan's tutorial, but I could not adapt it: tutorial. Here is my code: # RGB input, shape (224x224x3) img = self.inputImage # make to grayscale img = np.average(img, axis=2) rows, cols = img.shape[0], img.shape[1] color_mask = np.zeros((rows,

`QImage` constructor has unknown keyword `data`

帅比萌擦擦* 提交于 2019-11-26 14:51:50
问题 Suppose I am taking an image from the webcam using opencv. _, img = self.cap.read() # numpy.ndarray (480, 640, 3) Then I create a QImage qimg using img : qimg = QImage( data=img, width=img.shape[1], height=img.shape[0], bytesPerLine=img.strides[0], format=QImage.Format_Indexed8) But it gives an error saying that: TypeError: 'data' is an unknown keyword argument But said in this documentation, the constructor should have an argument named data . I am using anaconda environment to run this

What is the difference between an opencv BGR image and its reverse version RGB image[:,:,::-1]?

荒凉一梦 提交于 2019-11-26 11:40:12
问题 I\'m trying to show an opencv image with a QLabel. I got two different versions of the image, first one is the opencv BGR image, the second one is the RGB image using image[:,:,::-1], the BGR version works fine but the RGB version doesn\'t work. The following code works fine src = cv.imread(\'image.jpg\') h,w,ch = src.shape bytesPerLine = ch * w qImg = QImage(src.data, w, h, bytesPerLine, QImage.Format_RGB888) qImg = qImg.rgbSwapped() self.ui.label.setPixmap(QPixmap.fromImage(qImg)) These

cv::Mat to QImage and back

孤者浪人 提交于 2019-11-26 09:01:55
问题 //Sorry for my english. Tell me please, what I am doing wrong? I have read a lot about this. And write some code, but I have a terrible result. As I understand in Opencv CV_8UC3 is the same as QImage::Format_RGB888 , except BRG and RGB accordingly. to read cv::Mat in this format I can do: cv::Mat mat1 = cv::imread(\"bugero.jpg\",3); So, to convert cv::Mat to QImage I can do: QImage Mat2QImage(cv::Mat const& src) { cv::Mat temp(src.cols,src.rows,src.type()); cvtColor(src, temp,CV_BGR2RGB);

how to convert an opencv cv::Mat to qimage

吃可爱长大的小学妹 提交于 2019-11-26 01:49:37
问题 I am wondering how would I convert the OpenCV C++ standard cv::Mat type to Qimage. I have been searching around, but have no luck. I have found some code that converts the IPlimage to Qimage, but that is not what I want. Thanks 回答1: Michal Kottman's answer is valid and give expected result for some images but it'll fail on some cases. Here is a solution i found to that problem. QImage imgIn= QImage((uchar*) img.data, img.cols, img.rows, img.step, QImage::Format_RGB888); Difference is adding

how to convert an opencv cv::Mat to qimage

…衆ロ難τιáo~ 提交于 2019-11-26 01:36:32
I am wondering how would I convert the OpenCV C++ standard cv::Mat type to Qimage. I have been searching around, but have no luck. I have found some code that converts the IPlimage to Qimage, but that is not what I want. Thanks Michal Kottman's answer is valid and give expected result for some images but it'll fail on some cases. Here is a solution i found to that problem. QImage imgIn= QImage((uchar*) img.data, img.cols, img.rows, img.step, QImage::Format_RGB888); Difference is adding img.step part. qt won't complain without it but some images won't show properly without it. Hope this will