Results 1 to 14 of 14

Thread: Processing and Displaying Image on Widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Processing and Displaying Image on Widget

    Quote Originally Posted by anda_skoa View Post
    My guess is that you are accessing memory areas that are not valid while looping over the image.
    Your inner loop's step size is 1 uint per loop, an uint is usually 4 bytes.
    But your image format is one byte per pixel.
    oh, Wow!! I can't believe that I let this warning confuse me!!

    uchar *QImage::scanLine(int i)
    Returns a pointer to the pixel data at the scanline with index i. The first scanline is at index 0.
    The scanline data is aligned on a 32-bit boundary.
    Warning: If you are accessing 32-bpp image data, cast the returned pointer to QRgb* (QRgb has a 32-bit size) and use it to read/write the pixel value. You cannot use the uchar* pointer directly, because the pixel format depends on the byte order on the underlying platform. Use qRed(), qGreen(), qBlue(), and qAlpha() to access the pixels.
    thank you very much anda_skoa

    cheers

  2. #2
    Join Date
    Mar 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Processing and Displaying Image on Widget

    as you see in my code I posted at the beginning of this thread, I have bunch of classes already in my project and I am going to add a few more as I progress in my project. I came up with the idea to add a TextEdit to my mainwindow.ui and called it Console to display some text there through out my code.
    I want to be able to do this from all my classes.
    At first I thought there is no easier task than this, but apparently I can't find a solution.
    would you guys help me on this?

    cheers

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Processing and Displaying Image on Widget

    You have different options:

    - add signals that emit new "console" text to classes that need it and connect to the text edit or a slot in main window
    - pass the pointer to the text edit or main window to wherever this is needed
    - make the pointer to the text edit or the main window globally accessible

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    mhb88 (31st March 2016)

  5. #4
    Join Date
    Mar 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Processing and Displaying Image on Widget

    OK, I got everything working as the base of my project. At this point I can communicate with camera, and receive its frames, and just display them in my widget.
    But I have an issue.
    My camera supports up to 100 frames/sec, but I am barely displaying 15 frames/sec.
    My camera resolution is 480x640 and I am just receiving 8bits grayscale frames. So each frame has 480 x 640 x 8 = 300KBytes of data and if I want to receive them at rate of 100 fps, I have to receive them 300KBytes/frame x 100 frames/sec = 30000 KBytes/sec, about 30MBytes/sec, which is half of the speed of the USB2.0. So I think my USB2.0 should be able to do handle that amount of data transfer.

    So I think the issue is in my software, but I am not doing any processing in my code, I am just displaying frames. I have created a class with a paint event, and I have promoted a Qwidget to this class to display on it.

    I don't know if Qwidget can handle transferring this amount of data?
    Does any one has any suggestion or solution?

    cheers

  6. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Processing and Displaying Image on Widget

    For such high througput rendering you probably have to use a more direct rendering approach, e.g. OpenGL.

    It might be worthwhile to look into creating a QCamera backend and then use the existing video widget infrastructure.

    Cheers,
    _

  7. #6
    Join Date
    Mar 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Processing and Displaying Image on Widget

    Do you know any tutorials that start from foundation and builds up to it?
    I don't have any experience with OpenGL.
    I found most tutorials to be about QGLWidget.
    But in the new versions of Qt 5, QOpenGLWidget is intended to be a modern replacement for QGLWidget.
    I haven't been able find a good tutorial for QOpenGLWidget.

    cheers

  8. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Processing and Displaying Image on Widget

    No, sorry, I haven't had anything to do with that yet myself either.

    Cheers,
    _

  9. #8
    Join Date
    Mar 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Processing and Displaying Image on Widget

    I was wondering if this would work?
    a function is getting a pointer to a QImage as a parameter.
    I want to copy the entire QImage to a buffer of that is going to hold 100 QImages.

    Qt Code:
    1. public:
    2. void function(QImage *frame);
    3.  
    4. protected:
    5. enum{size = 100};
    6. QImage *data[size];
    7. int front; // points to the front of the buffer
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void Buffer::function(QImage *frame)
    2. {
    3. ++front; // Increment front.
    4. if (front == size)
    5. front = 0; // Wrap around.
    6.  
    7. data[front] = frame;
    8. }
    To copy to clipboard, switch view to plain text mode 

    cheers

  10. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Processing and Displaying Image on Widget

    Sure, why not.
    I assume you handle deletion of the QImage pointers somewhere else?

    Cheers,
    _

Similar Threads

  1. Replies: 7
    Last Post: 2nd December 2013, 16:06
  2. image processing
    By IRON_MAN in forum Qt Programming
    Replies: 4
    Last Post: 18th November 2009, 13:37
  3. Image processing
    By NicNac in forum Newbie
    Replies: 25
    Last Post: 2nd November 2008, 10:05
  4. Image processing via matrix
    By jones.79 in forum Qt Programming
    Replies: 10
    Last Post: 22nd September 2008, 00:42
  5. Image Processing using Qt
    By danielperaza in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2008, 18:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.