Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: Image processing

  1. #1
    Join Date
    Aug 2008
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Image processing

    Hi guys
    Im new to Qt currently installed Qt4 on Mac OS X, I read through some of the documentation (C++-GUI-Programming-with-Qt-4-1st-ed), but it only gives some basic stuff. I want to load multiple images from the hard disk and display them one after the ohter in a GUI program. I need a starting point. please lead the way im prepared to do all that is needed from my part.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image processing

    I need a starting point. please lead the way im prepared to do all that is needed from my part.
    Refer the Image Viewer example in Qt Demo.

    You can very easily show an image on a QLabel. If you want to show multiple images in a single area, you can use QLabel with QTimer to get the effect of slideshow.

    Otherwise, you can add QLabel in a layout and display multiple images

    Hope this helps

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    A starting point would be to read about QLabel, QPixmap and QTimer.

  4. #4
    Join Date
    Aug 2008
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Image processing

    thanks guy i'll give it a look

  5. #5
    Join Date
    Aug 2008
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Image processing

    Now i can load photos, but i can only do it when i know the exact names of the files. My next mission is to browse a folder and load all the pictures (jpg format for now), display them one after another (a slide show kind of thing). Any suggestions?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing


  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Image processing

    Or may be QFileDialog::getOpenFileNames .
    QFileDialog::getOpenFileNames(this,"Select one or more files to open","/home","Images (*.png *.xpm *.jpg)");

  8. #8
    Join Date
    Aug 2008
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Image processing

    Thanks guys for all your help, i'm making progress on my application. Next mission, I want to customize buttons by say linking the file browsing action with a button. The only options i can find is the ones preinstalled. should i define my own slots or is there a better way?

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    Read a tutorial and browse Qt Assistant please

  10. The following user says thank you to wysota for this useful post:

    aurelius (30th October 2008)

  11. #10
    Join Date
    Aug 2008
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Image processing

    Hi,

    i am trying to do a slideshow. I have the images load and everything else work i.e. next, back between the pictures.

    I would like to automate it with Qtimer, i call the method to start the slideshow in the method i use the Qtimer like this:


    Qt Code:
    1. QTimer *timer = new QTimer(this);
    2. connect(timer, SIGNAL(timeout()), this, SLOT(nextPicture()));
    3. timer->start(30000);
    To copy to clipboard, switch view to plain text mode 

    Is this the write way?

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    Yes, this is ok.

  13. #12
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    Hi, I am a newbie in QT4, however really enthusiastic with all the capabilities of it.

    What I want to do is to have a grid of images, and display them, like this program

    http://www.youtube.com/watch?v=kVcTMAUr3Bw

    I mean, I want to display them in a grid and if possible, when I resize the window, the grid and the images contained in it to adjust. I guess I will have to follow

    these instructions:
    Quote Originally Posted by aamer4yu View Post
    Refer the Image Viewer example in Qt Demo.

    Otherwise, you can add QLabel in a layout and display multiple images

    Hope this helps
    Is this right? I guess, in order for the images to adjust, I will have to use grid layout. Because I can't really recall right now, is it possible to dynamically add widgets inside the QGridLayout, that is I check what images are contained in a directory and display them in a grid mode ? Is this right?

    Do you have any other advice or sample code that does sth similar?

    P.S. I just found this forum, which was a relief, because the tutorials in QT4 website are basic.

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    I think this is dome using GraphicsView so take a look at QGraphicsView and QGraphicsScene.

  15. The following user says thank you to wysota for this useful post:

    aurelius (30th October 2008)

  16. #14
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    Thanx for the quick answer.

    Do you know iff there is somewhere some demo code for QGraphcisScene etc ? Of course, I will try to figure out how it works, but it's kinda difficult by just reading the properties of it, since I am just a beginner.

    Ok, I just realized that there are some tutorials in QT4 site.
    Last edited by aurelius; 29th October 2008 at 18:24.

  17. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    Open a terminal and type in "assistant".

  18. The following user says thank you to wysota for this useful post:

    aurelius (30th October 2008)

  19. #16
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    I use Ubuntu 8.04 and I program with just a text editor and console. Unfortunately the repositories don't have the latest version of Qt, so QGraphicsProxyWidget are not part of the library. Of course, I don't know if it's even useful, but ok, I just don't have access on it. Also, there are not the functions that are related to it, such as the addWidget in QGraphicsScene. This function I guess it's really important. I downloaded and compiled the newer version of Qt, however the makefile throws error. I use a modified qmake that I took from a QDevelop program and it has some include paths. I changed them and it suddenly started to throw some errors. Do you have any qmake that it would work properly?

    I think I will have to create my own makefiles with my own qmake, but that is a problem.

    Whatsoever, I tried to do sth with grid layout. I managed to put two images in a grid layout, so I guess I can do it for more images. However, I don't know how to do it, so as automatically to change for the position of those images acoording to the with of the main window. I will try to make QGraphics class work properly, but do you have any idea for this as well?
    Last edited by aurelius; 29th October 2008 at 21:13.

  20. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    Quote Originally Posted by aurelius View Post
    Of course, I don't know if it's even useful, but ok, I just don't have access on it.
    Not in your case. You need a plain graphicsview and QGraphicsPixmapItems.

    Do you have any qmake that it would work properly?
    Always use only the instance of qmake that comes with your installation, be it a binary or an own build originated.

    I think I will have to create my own makefiles with my own qmake, but that is a problem.
    No, you need to read a tutorial or two. Don't make things more complex than they are.

    Whatsoever, I tried to do sth with grid layout. I managed to put two images in a grid layout, so I guess I can do it for more images.
    Forget it. Read about QGraphicsView, pretty please.

  21. #18
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default

    Yeah I think you are right. This is what I am doing now.

    Well, I think now I have found the info I needed for the first and basic task I wanted to do: to order images one after the other in a grid. I found the drill down example which does a similar thing. Now, i would like the grid to refresh, an adjust the number of images it shows, according to the width of the window. Except for the way, with which I catch the event of resizing the window, computing the dimensions, comparing them with image dimensions and setting the new GraphicsPixmapItem coordinates, is there any automatic way for doing all these ?
    Last edited by wysota; 29th October 2008 at 23:50.

  22. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    No, you have to modify the scene size to reflect the view's viewport size and react on scene resizes. Basically all should be done in the scene apart from resizing the scene itself.

  23. #20
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    From what you saying, I understand this:

    1) I have to create a QGraphicsScene item. From all the reading I ve made, this is the class that manages all items inside the area.

    2) I have to create a QGraphicsView item. This item is for visualizing the whatever contents of QGraphicsScene.

    3) I add items in the QGraphicsScene. I use the function addPixmap. I add them to the scene and display them. However, the documentation says, that items are by default positioned to (0,0). So, if I add 2 items, the second overlaps the first. I can change the position of the item with the use of GraphicsPixmapItem->setOffset(...). What I was trying all along to find out is the following: in order to have several pixmap items in the scene, and order them into a grid, how do I define the position of the items? Is there some function that layouts them like that or I have to define myself the position of the items with setOffset() function ? That is, is there any function that says to the scene:
    "ok, put this pixmap from top to right, where there is empty space" because from what I ve read till now(and maybe because I am a beginner in GUIs), the only function I can do is "ok, put the pixmap in (0,0), if the programmer wants sth else, he will change it by himself later".

    4) I understand what you are saying with the size and stuff. What I don't understand is the following: I can define the scene rect. When I show the QGraphicsView, doesn't it show this rect ? What do you mean, that the scene size must reflect the view's size. The documentation says, that if you don't mess with QGraphicsView's sceneRect, it takes by default the rect of the QGraphicsScene, which means the one rect relfects to the other. Or not ?
    Last edited by aurelius; 30th October 2008 at 12:21.

Similar Threads

  1. Image processing via matrix
    By jones.79 in forum Qt Programming
    Replies: 10
    Last Post: 22nd September 2008, 01:42
  2. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 16:36
  3. Image Processing using Qt
    By danielperaza in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2008, 19:15
  4. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 03:10
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 17:36

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.