Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CSequence and getSimilarity function



Hi,

a simple question about getSimilarity() function. Finally i was able to
write a few lines of code that allow to finds shots (more or less). The
getSimilarity function returns the similarity about 2 frames and works fine.
When the 2 frames are very differents returns 0. The problem are that only
works if the movie visualizes in the screen. I need to write a process in
background mode. It is possible to compare 2 frames in a QTCanvas that is
invisble in the screen?. Thanks a lot.

int timeScale = m.getTimeScale(); //m, a movie read from a URL
int duration = m.getDuration();
float rate = timeScale * 0.1;
int numFrames = (int)(duration / rate) + 1;

MoviePlayer myPlayer = new MoviePlayer (m);
MoviePlayer mp = (MoviePlayer)myPlayer;
myQTCanvas.setClient (myPlayer, true);

QDRect rect = mp.getDisplayBounds();
QDGraphics gw = myQTCanvas.getPort();
int size = QTImage.getMaxCompressionSize
(gw,rect,gw.getPixMap().getPixelSize(),codecMaxQuality,
kSorensonCodecType,
CodecComponent.bestFidelityCodec);
QTHandle imageHandle = new QTHandle (size, true);
imageHandle.lock();
RawEncodedImage compressedImage = RawEncodedImage.fromQTHandle(imageHandle);
CSequence seq = new CSequence
(gw,rect,gw.getPixMap().getPixelSize(),kSorensonCodecType,
CodecComponent.bestFidelityCodec,
codecMaxQuality,
codecMaxQuality,
numFrames,
null, //cTab,
1);
ImageDescription desc = seq.getDescription();
pack();
((Playable)myPlayer).setRate(1);

int pos = 0;
int i=0;
while (i<numFrames)
{
mp.setTime(pos);
mp.redraw(null);
CompressedFrameInfo info = seq.compressFrame
(gw,rect,codecFlagUpdatePrevious,compressedImage);
boolean isKeyFrame = info.getSimilarity() == 0;
System.out.println ("f#:" + i + ",pos=" + pos + ",kf=" + isKeyFrame +
",sim=" + info.getSimilarity());
if (isKeyFrame)
{
listShots.add(new String(""+pos));
}
i++;
pos += rate;
}

Bye.

Esteban Luengo
_______________________________________________
quicktime-java mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/quicktime-java
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.