qimage

displaying image using a label

此生再无相见时 提交于 2019-12-01 09:02:38
问题 I have converted a numpy array into a pixmap to display it on a label within my GUI. When I run the program, the GUI closes for some reason (no error messages). height, width = input_image.shape bytesPerLine = 3 * width qImg = QtGui.QImage(input_image.data, width, height, bytesPerLine, QtGui.QImage.Format_RGB888) pixmap01 = QtGui.QPixmap.fromImage(qImg) self.pixmap_image = QtGui.QPixmap(pixmap01) self.ui.label_imageDisplay.setPixmap(self.pixmap_image) self.ui.label_imageDisplay.setAlignment

How to output this 24 bit image in Qt

荒凉一梦 提交于 2019-12-01 01:41:15
I have an unsigned char array that is defined like so: unsigned char **chars = new unsigned char *[H]; for(int i = 0; i < H; i++) { chars[i] = new unsigned char[W*3]; } Where H is the height of the image, and W is the width, and chars is populated in the rest of that function looping over rows x columns of the input image. Chars is populated in the order Red Green Blue I am trying to read it with something like this: QImage *qi = new QImage(imwidth, imheight, QImage::Format_RGB888); for (int i = 0 ; i < imheight ; i++) for (int j = 0 ; j < imwidth ; j++) { //not sure why, but have to flip j

convert QVideoFrame to QImage

六月ゝ 毕业季﹏ 提交于 2019-12-01 01:38:52
问题 I want to get every frames from a QMediaPlayer and convert it to QImage (or cv::Mat ) so I used videoFrameProbed signal from QVideoProbe : connect(&video_probe_, &QVideoProbe::videoFrameProbed, [this](const QVideoFrame& currentFrame){ //QImage img = ?? } But I didn't find any way for getting QImage from QVideoFrame ! How can I convert QVideoFrame to QImage ?! 回答1: You can use QImage's constructor: QImage img( currentFrame.bits(), currentFrame.width(), currentFrame.height(), currentFrame

How to output this 24 bit image in Qt

不羁岁月 提交于 2019-11-30 20:48:17
问题 I have an unsigned char array that is defined like so: unsigned char **chars = new unsigned char *[H]; for(int i = 0; i < H; i++) { chars[i] = new unsigned char[W*3]; } Where H is the height of the image, and W is the width, and chars is populated in the rest of that function looping over rows x columns of the input image. Chars is populated in the order Red Green Blue I am trying to read it with something like this: QImage *qi = new QImage(imwidth, imheight, QImage::Format_RGB888); for (int

With C++ and Qt how do I display a 16-bit raw file as an image?

独自空忆成欢 提交于 2019-11-29 11:57:21
I am looking to display heightmaps from the video game Battlefield 2 as images in my application. I am new to C++ and Qt and it might be straight forward but what I am having trouble with is displaying a grayscale 16-bit 1025x1025 2101250 bytes image. There is no header to the file. I need access to the displayed pixels (does not have to be pixel perfect precision) so I can point to a pixel and get its value. What I have tried I have loaded the binary data into a QByteArray from a QFile and I have attempted to use the QImage::fromData function to make the image but I am making a lot of

Qimage to cv::Mat convertion strange behaviour

99封情书 提交于 2019-11-29 11:19:13
I am trying to create an application where I am trying to integrate opencv and qt. I managed successfully to convert a cv::Mat to QImage by using the code below: void MainWindow::loadFile(const QString &fileName) { cv::Mat tmpImage = cv::imread(fileName.toAscii().data()); cv::Mat image; if(!tmpImage.data || tmpImage.empty()) { QMessageBox::warning(this, tr("Error Occured"), tr("Problem loading file"), QMessageBox::Ok); return; } /* Mat to Qimage */ cv::cvtColor(tmpImage, image, CV_BGR2RGB); img = QImage((const unsigned char*)(image.data), image.cols, image.rows, QImage::Format_RGB888);

Convert Python Opencv Image (numpy array) to PyQt QPixmap image

会有一股神秘感。 提交于 2019-11-28 19:00:22
I am trying to convert python opencv image to QPixmap. I follow the instruction shows Page Link and my code is attached below img = cv2.imread('test.png')[:,:,::1]/255. imgDown = cv2.pyrDown(img) imgDown = np.float32(imgDown) cvRGBImg = cv2.cvtColor(imgDown, cv2.cv.CV_BGR2RGB) qimg = QtGui.QImage(cvRGBImg.data,cvRGBImg.shape[1], cvRGBImg.shape[0], QtGui.QImage.Format_RGB888) pixmap01 = QtGui.QPixmap.fromImage(qimg) self.image01TopTxt = QtGui.QLabel('window',self) self.imageLable01 = QtGui.QLabel(self) self.imageLable01.setPixmap(pixmap01) The code has no compile and runtime error but the

Using QImage with OpenGL

ⅰ亾dé卋堺 提交于 2019-11-28 08:38:15
I've very recently picked up Qt and am using it with OpenGL The thing though is that when moving my SDL code to Qt and changing the texture code to use QImage it stops working. The image does load correctly, as shown through the error checking code. Thanks! P.S: Please don't suggest I use glDrawPixels, I need to fix the problem at hand. Some of the reasons for that being 1. slow 2. android (which this code may be running on eventually) is OpenGL ES and does not support glDrawPixels Here's the code: //original image QImage img; if(!img.load(":/star.png")) { //loads correctly qWarning("ERROR

With C++ and Qt how do I display a 16-bit raw file as an image?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 06:02:39
问题 I am looking to display heightmaps from the video game Battlefield 2 as images in my application. I am new to C++ and Qt and it might be straight forward but what I am having trouble with is displaying a grayscale 16-bit 1025x1025 2101250 bytes image. There is no header to the file. I need access to the displayed pixels (does not have to be pixel perfect precision) so I can point to a pixel and get its value. What I have tried I have loaded the binary data into a QByteArray from a QFile and I

Qimage to cv::Mat convertion strange behaviour

我怕爱的太早我们不能终老 提交于 2019-11-28 04:39:13
问题 I am trying to create an application where I am trying to integrate opencv and qt. I managed successfully to convert a cv::Mat to QImage by using the code below: void MainWindow::loadFile(const QString &fileName) { cv::Mat tmpImage = cv::imread(fileName.toAscii().data()); cv::Mat image; if(!tmpImage.data || tmpImage.empty()) { QMessageBox::warning(this, tr("Error Occured"), tr("Problem loading file"), QMessageBox::Ok); return; } /* Mat to Qimage */ cv::cvtColor(tmpImage, image, CV_BGR2RGB);