Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Convert an image cv::Mat to QImage
Qt 6.11 is out! See what's new in the release blog

Convert an image cv::Mat to QImage

Scheduled Pinned Locked Moved 3rd Party Software
2 Posts 2 Posters 5.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isaacEnrique
    wrote on last edited by
    #1

    Greetings.

    I'm working on a project with Qt + OpenCV and I need to convert an image cv::Mat to QImage and / or viceversa. Does anyone know how to do?

    Thanks in advance for any answers or comments.

    Isaac Pérez
    Programming is understanding.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hello,

      If you are using one of the types supported by QImage, you can use the constructor taking an (const) uchar * input.

      And the same in reverse, get the data from QImage with the bits function.

      As the doc state, look carefully for the lifetime of your data.

      http://qt-project.org/doc/qt-4.8/qimage.html#QImage-4 and its friends

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved