Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. About Qt QImage::Format and OpenCV
Forum Updated to NodeBB v4.3 + New Features

About Qt QImage::Format and OpenCV

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • E Offline
    E Offline
    Ehehe
    wrote on last edited by Ehehe
    #1
    • Environment : Lenovo notepad-PC Y430P, Win10 64bit, Qt5.10.0, Visual Studio2017, OpenCV3.4.0 / Python3.6, opencv_python3.3.1

    • Scenario: Programming in Python, face recognition in image and video, everything is OK, using notepad-PC's own camera. However programming in Qt, recognition in image is OK, problem occurs in video.

    • Questions: #1 can = cvCreateCameraCapture(-1);return a address pointer, pretend it return right. pFrame = cvQueryFrame(cam); but this function return NULL! Why can not get frame from video steam? It is a question about opencv, I hope anyone can answer in Qt forum, lucky enough. ^_^
      #2 I think it maybe something wrong with the notepad-PC own camera, so I use USB camera, in this way pFrame = cvQueryFrame(cam); return non-NULL, I display the image in graphics view, but all gray. Code:

    pFrame = cvQueryFrame(cam);
    QImage image((const uchar *)pFrame->imageData, pFrame->width, pFrame->height, QImage::Format_RGB888);
    QGraphicsScene *scene = new QGraphicsScene;
    scene->addPixmap(QPixmap::fromImage(image));
    ui.graphicsView->setScene(scene);
    ui.graphicsView->show();
    

    Maybe the format is wrong, but I have trid all the variable QImage::Format_*** no one is right, How to distinguish format of image, in another way, when I use QImage::Format_RGB888, when I use other? I hope someone can tell me or provide some information link.

    Thanks.

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

      Hi,

      Did you check the format of the camera video stream ? You might have to convert it first before doing something with it with Qt.

      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
      • E Offline
        E Offline
        Ehehe
        wrote on last edited by
        #3

        Sorry, last week I was busy with work, have no time to learn Qt, so even though I saw your comment, I did not respond to you.

        Today I have tried the example in Qt install path, the program can find two camera: notepad-PC own camera and USB camera, and successfully show the video when I choose each one.

        The USB camera is an old one, I can not find its instructions, how can I get the format of the video stream? Is there any function in Qt can get the video format?

        I use the software in Windows 10 - Camera to record, the files of two camera are all .mp4. Is mp4 is the video format? And is right to use QImage::Format_RGB888?

        I have so much questions, and hope you can answer patiently, thanks very very very much! ^_^

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

          Ok, so now what are you using to get the image from your camera ?

          You can operate a colourspace conversion with OpenCV so that you ensure you are using RGB 8bit and then transformed into a QImage/QPixmap as needed.

          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