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. Display Qbytearray as Image in QT 5.12.9 version

Display Qbytearray as Image in QT 5.12.9 version

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 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.
  • P Offline
    P Offline
    Pooja Bhusare
    wrote on last edited by Pooja Bhusare
    #1

    I am reading the QByteArray using QTcpSocket and converting the array into the cvMat image. to display the image using imshow().but i am getting gray image. code is as follows.
    cv::Mat img,img1;
    img.cols=320;
    img.rows=240;
    img = cv::Mat(240,320, CV_8UC1,array.data());
    cv::cvtColor(img, img, CV_GRAY2RGB); //
    cv::imshow("image display",img);
    cv::waitKey(5000);

    after cvtColour() function also its not converting into colour image.

    Thanks in advance.

    JonBJ Pablo J. RoginaP 2 Replies Last reply
    0
    • P Pooja Bhusare

      I am reading the QByteArray using QTcpSocket and converting the array into the cvMat image. to display the image using imshow().but i am getting gray image. code is as follows.
      cv::Mat img,img1;
      img.cols=320;
      img.rows=240;
      img = cv::Mat(240,320, CV_8UC1,array.data());
      cv::cvtColor(img, img, CV_GRAY2RGB); //
      cv::imshow("image display",img);
      cv::waitKey(5000);

      after cvtColour() function also its not converting into colour image.

      Thanks in advance.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Pooja-Bhusare
      Start by determining whether it's your code not doing what you want with correct data, or whether you're not transferring/receiving the right stuff over socket. The two issues are quite independent of each other, you need to know which of the two is problematic.

      1 Reply Last reply
      0
      • P Pooja Bhusare

        I am reading the QByteArray using QTcpSocket and converting the array into the cvMat image. to display the image using imshow().but i am getting gray image. code is as follows.
        cv::Mat img,img1;
        img.cols=320;
        img.rows=240;
        img = cv::Mat(240,320, CV_8UC1,array.data());
        cv::cvtColor(img, img, CV_GRAY2RGB); //
        cv::imshow("image display",img);
        cv::waitKey(5000);

        after cvtColour() function also its not converting into colour image.

        Thanks in advance.

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @Pooja-Bhusare said in Display Qbytearray as Image in QT 5.12.9 version:

        i am getting gray image

        Well, should it be the expected behavior? I mean, since you're doing:

        cv::cvtColor(img, img, CV_GRAY2RGB)
        

        and CV_GRAY2RGB will convert grayscale to RGB color space but it won't color your already gray image...
        See this answer in SO.

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pooja Bhusare
          wrote on last edited by
          #4

          @JonB said in Display Qbytearray as Image in QT 5.12.9 version:

          Start by determining whether it's your code not doing what you want with correct data, or whether you're not transferring/receiving the right stuff over socket. The two issues are quite independent of each other, you need to know which of the two is problematic.

          Yes , problem is resolved i am not receiving complete buffer socket Thanks

          Pablo J. RoginaP 1 Reply Last reply
          0
          • P Pooja Bhusare

            @JonB said in Display Qbytearray as Image in QT 5.12.9 version:

            Start by determining whether it's your code not doing what you want with correct data, or whether you're not transferring/receiving the right stuff over socket. The two issues are quite independent of each other, you need to know which of the two is problematic.

            Yes , problem is resolved i am not receiving complete buffer socket Thanks

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @Pooja-Bhusare said in Display Qbytearray as Image in QT 5.12.9 version:

            problem is resolved

            great, so please don't forget to mark your post as solved!

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            P 1 Reply Last reply
            0
            • Pablo J. RoginaP Pablo J. Rogina

              @Pooja-Bhusare said in Display Qbytearray as Image in QT 5.12.9 version:

              problem is resolved

              great, so please don't forget to mark your post as solved!

              P Offline
              P Offline
              Pooja Bhusare
              wrote on last edited by
              #6

              @Pablo-J-Rogina

              I am trying to convert the cv mat image to Qimage but facing error: ‘class Ui::MainWindow’ has no member named ‘display_image’

              Pablo J. RoginaP 1 Reply Last reply
              0
              • P Pooja Bhusare

                @Pablo-J-Rogina

                I am trying to convert the cv mat image to Qimage but facing error: ‘class Ui::MainWindow’ has no member named ‘display_image’

                Pablo J. RoginaP Offline
                Pablo J. RoginaP Offline
                Pablo J. Rogina
                wrote on last edited by
                #7

                @Pooja-Bhusare said in Display Qbytearray as Image in QT 5.12.9 version:

                but facing error: ‘class Ui::MainWindow’ has no member named ‘display_image’

                Should that issue be a new post on its own?

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                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