I\'m looking to create a function for converting a QImage into OpenCV\'s (CV2) Mat format from within the PyQt.
How do I do this? My input images I\'ve been working
I tried the answer given above, but couldn't get the expected thing. I tried this crude method where i saved the image using the save() method of the QImage class and then used the image file to read it in cv2
Here is a sample code
def qimg2cv(q_img):
q_img.save('temp.png', 'png')
mat = cv2.imread('temp.png')
return mat
You could delete the temporary image file generated once you are done with the file. This may not be the right method to do the work, but still does the required job.