PDA

View Full Version : Playing Image Sequence using Qt



Nfrancisj
12th February 2016, 10:39
Hello All,
I'm trying to build a simple player that plays a image sequence. I'm having a lot of trouble finding examples of this in Qt forum. I'm using PyQt, and I'm reading my way through QLabel .
What I would like to know is,

How do I read in a image sequence?
How would I go about playing it in QLabel? (I assume QLabel is what I want to use?)
How do I make a simple timeline so I can pause, start, stop and scrub the image sequence?

Any help would be greatly appreciated!

Thx

anda_skoa
12th February 2016, 13:29
In what way do you have access to the images?
Are they in a directory on disk?
Do you need to just show a single image at any given time, replacing one with the next at regular intervals?

Cheers,
_

Nfrancisj
12th February 2016, 18:23
I have a folder on my local drive.

D:\ElementLibrary\Fire\Fire01\Fire01.001.jpeg
D:\ElementLibrary\Fire\Fire01\Fire01.002.jpeg
.....
Here is a mockup of what I want to make. So...there's a viewer where the car is. Under that is a little timeline that can be used to play oR change frames. When I click on a image in the file browser I want it to automatically start playing.
http://i67.tinypic.com/5347k3.jpg

The interface is not an issue...yet...just playing the files. A few people have suggest using Phonon.VideoPlayer. But how do I get it to play image sequence.

Here is a vid of what someone made. The is the main idea...
https://vimeo.com/41345071


Cheers!

anda_skoa
13th February 2016, 11:34
You don't have a video so don't bother with a video player.

1) List the directory. QDir::entryInfoList(), and store it the result in a class member

2) Create a QTimeLine object and connect a local slot to its frameChanged() signal

3) Set the timeline's frame range form 0 to the number of items in your file list

4) Start the time line

5) In the slot connected to frameChanged() get the respective entry from the file list, load into a QPixmap and put that onto the label.

Cheers,
_

Nfrancisj
13th February 2016, 11:56
Oh my! I think that just went over my head. Hahaha! Might be too advance for me I think.
I have to read up on qtimeline and pixmap.

Thank you very much for the direction. I appreciate it. Are there any example code somewhere you can adjust?

Nfrancisj
14th February 2016, 10:19
2) Create a QTimeLine object and connect a local slot to its frameChanged() signal

5) In the slot connected to frameChanged() get the respective entry from the file list, load into a QPixmap and put that onto the label.
_

Can pls explain a bit more on #2 & #5 ?
I don't understand what you mean by connect a local slot to frameChanged()
I have:

JpegSeq_PlaceHolderArray // will be Qdir stuff

QTimelime myTimeline;

myTimeline.frameChanged(JpegSeq_PlaceHolderArray) // setting frame seq into frame changed.

Thx.

Added after 18 minutes:


Can pls explain a bit more on #2 & #5 ?
I don't understand what you mean by connect a local slot to frameChanged()
I have:

JpegSeq_PlaceHolderArray // will be Qdir stuff

QTimelime myTimeline;

myTimeline.frameChanged(JpegSeq_PlaceHolderArray) // setting frame seq into frame changed.

Thx.


Sorry disregard this. I found the class in the docs. http://srinikom.github.io/pyside-docs/PySide/QtCore/QTimeLine.html

...
progressBar = QProgressBar(self)
progressBar.setRange(0, 100)

# Construct a 1-second timeline with a frame range of 0 - 100
timeLine = QTimeLine(1000, self)
timeLine.setFrameRange(0, 100)
timeLine.frameChanged[int].connect(progressBar.setValue)

# Clicking the push button will start the progress bar animation
pushButton = QPushButton(QObject.tr("Start animation"), self)
pushButton.clicked.connect(timeLine.start)
...

anda_skoa
14th February 2016, 11:54
And a local slot would be a method of the current class, something like

....connect(self.showNextImage)

def showNextImage(index)

Cheers,
_

Nfrancisj
14th February 2016, 20:18
Yes, hahaha. I knew the operation, but not the Term local slot. ;)
Thanks again. I'm sure I'll be back with more questions.

Cheers!