Results 1 to 2 of 2

Thread: Visualization and Threads

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Visualization and Threads

    Hi,

    I've developed an application that uses 2 QThreads to capture and process images captured from a camera(live capture):
    -First thread capture images from a camera
    -Second thread process the images
    -The two threads share the same image buffer(with QWaitCondition to lock them)
    -Main thread recives pointer to image buffer to display them

    To speed up the process the process thread emits a pointer to the image buffer to display.
    The problem is that the capture and process threads are well synchronized but the main thread can stay displaying the image when the capturing thread writes a new image on the same image pointer. Then the application crash(only using multiple CPUs, but is normal that on a signle CPU to not crash).
    One solution is to emit images as copy instead of pointer but it decreases a lot the application performance.

    Any idea how to lock the capture thread when the main thread is displaying the image and viceversa?

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Visualization and Threads

    Quote Originally Posted by ^NyAw^ View Post
    One solution is to emit images as copy instead of pointer but it decreases a lot the application performance.
    Have you actually tried this? QImage's copy-on-write mechanism makes passing QImages by value virtually a no-op.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.