Menu

Conversion between dlib::array2d<dlib::rgb_pixel> and qt::QImage.

Help
2016-04-18
2019-02-14
  • Facundo Jose Cancino

    Hello. I am creating a program with QT and using dlib for object detection. In some point I need to show an image via QT generated GUI, so I want to convert a dlib::array2d<dlib::rgb_pixel> to qt::QImage. Any suggestion on how to do that? I am stuck. An alternative could be conversion to Opencv image format, cv::Mat, and then converting cv::Mat to QImage, but I want to avoid that unnecesary step. Anyway, help converting dlib's format to cv::Mat will be apreciated too, I found in this forum information regarding only the inverse convertion.
    Thanks in advance.</dlib::rgb_pixel>

     
    • Davis

      Davis - 2016-04-18

      You can use dlib::toMat() to convert to opencv. I've never used Qt's image
      object so I don't know what you would use there.

       
    • Evgeniy

      Evgeniy - 2016-05-11

      Hi, you can use QImage contructor that creates image from memory buffer:
      http://doc.qt.io/qt-5/qimage.html#QImage-6

      To get pointer from array2d you can look into dlib/array2d/array2d_generic_image.h and use dlib::image_data function

      QImage's constructor does not copy memory buffer, so you should make array2d to exists in memory until QImage's destructor called - QImage has cleanup function for it and you can find samples on stackoverflow

       
  • stan-sack

    stan-sack - 2017-05-18

    I don't know if you ever solved this but its probably because of the order of your #includes. Move all the opencv and dlib stuff before foundation.h

     
  • mehrdad shoebyri

    you can use https://github.com/mshobeyri/QFaceRecognition repo that is a qt/qml wrapper on dlib.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.