Skip to content

Commit

Permalink
changes for new OF video player before YCAM installation
Browse files Browse the repository at this point in the history
  • Loading branch information
obviousjim committed Aug 14, 2012
1 parent f77e083 commit 1419b16
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 125 deletions.
18 changes: 14 additions & 4 deletions Renderer/ScreenLabRenderer.xcodeproj/project.pbxproj
Expand Up @@ -76,7 +76,9 @@
E738E8EA153C69D600BDA0F3 /* ofxRGBDMediaTake.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E738E8E9153C69D600BDA0F3 /* ofxRGBDMediaTake.cpp */; };
E738E8F1153C922D00BDA0F3 /* ofxDepthImageSequence.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E738E8EF153C922C00BDA0F3 /* ofxDepthImageSequence.cpp */; };
E738E8F3153CB00500BDA0F3 /* ofxRGBDRenderSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E738E8F2153CB00400BDA0F3 /* ofxRGBDRenderSettings.cpp */; };
E790FB991560AF280047F0F7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E790FB981560AF280047F0F7 /* libz.dylib */; };
E7F29E7A15DAA3A60016AF67 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E7F29E7915DAA3A60016AF67 /* libz.dylib */; };
E7F29E7C15DAA4880016AF67 /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7F29E7B15DAA4880016AF67 /* QTKit.framework */; };
E7F29E7E15DAA4B10016AF67 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7F29E7D15DAA4B10016AF67 /* CoreVideo.framework */; };
E7F41290156291C800B299D9 /* ofxBaseGui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E7F41285156291C800B299D9 /* ofxBaseGui.cpp */; };
E7F41291156291C800B299D9 /* ofxButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E7F41287156291C800B299D9 /* ofxButton.cpp */; };
E7F41292156291C800B299D9 /* ofxPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E7F4128A156291C800B299D9 /* ofxPanel.cpp */; };
Expand Down Expand Up @@ -307,7 +309,9 @@
E738E8F0153C922D00BDA0F3 /* ofxDepthImageSequence.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxDepthImageSequence.h; sourceTree = "<group>"; };
E738E8F2153CB00400BDA0F3 /* ofxRGBDRenderSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxRGBDRenderSettings.cpp; sourceTree = "<group>"; };
E738E8F4153CB03700BDA0F3 /* ofxRGBDRenderSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ofxRGBDRenderSettings.h; sourceTree = "<group>"; };
E790FB981560AF280047F0F7 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
E7F29E7915DAA3A60016AF67 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib/libz.dylib; sourceTree = SYSTEM_DEVELOPER_DIR; };
E7F29E7B15DAA4880016AF67 /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/QTKit.framework; sourceTree = SYSTEM_DEVELOPER_DIR; };
E7F29E7D15DAA4B10016AF67 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/CoreVideo.framework; sourceTree = SYSTEM_DEVELOPER_DIR; };
E7F41283156291C800B299D9 /* ofOscParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofOscParameter.h; sourceTree = "<group>"; };
E7F41284156291C800B299D9 /* ofParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofParameter.h; sourceTree = "<group>"; };
E7F41285156291C800B299D9 /* ofxBaseGui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxBaseGui.cpp; sourceTree = "<group>"; };
Expand All @@ -329,7 +333,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E790FB991560AF280047F0F7 /* libz.dylib in Frameworks */,
E7F29E7E15DAA4B10016AF67 /* CoreVideo.framework in Frameworks */,
E7F29E7C15DAA4880016AF67 /* QTKit.framework in Frameworks */,
E7F29E7A15DAA3A60016AF67 /* libz.dylib in Frameworks */,
E4EB6799138ADC1D00A09F29 /* GLUT.framework in Frameworks */,
E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */,
E45BE97B0E8CC7DD009D7055 /* AGL.framework in Frameworks */,
Expand Down Expand Up @@ -432,7 +438,9 @@
BBAB23C913894ECA00AA2426 /* system frameworks */ = {
isa = PBXGroup;
children = (
E790FB981560AF280047F0F7 /* libz.dylib */,
E7F29E7D15DAA4B10016AF67 /* CoreVideo.framework */,
E7F29E7B15DAA4880016AF67 /* QTKit.framework */,
E7F29E7915DAA3A60016AF67 /* libz.dylib */,
E4C2424410CC5A17004149E2 /* AppKit.framework */,
E4C2424510CC5A17004149E2 /* Cocoa.framework */,
E4C2424610CC5A17004149E2 /* IOKit.framework */,
Expand Down Expand Up @@ -1285,6 +1293,7 @@
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_9 = "\"$(SRCROOT)/../../../addons/ofxOsc/libs/oscpack/lib/win_cb\"";
PREBINDING = NO;
PRODUCT_NAME = ScreenLabRendererDebug;
SDKROOT = macosx10.7;
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand Down Expand Up @@ -1389,6 +1398,7 @@
LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_9 = "\"$(SRCROOT)/../../../addons/ofxOsc/libs/oscpack/lib/win_cb\"";
PREBINDING = NO;
PRODUCT_NAME = ScreenLabRenderer;
SDKROOT = macosx10.7;
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
18 changes: 13 additions & 5 deletions Renderer/bin/data/localsettings.xml
Expand Up @@ -5,17 +5,25 @@
<screenRect>
<x>0</x>
<y>0</y>
<w>360</w>
<h>1200</h>
<w>600</w>
<h>1920</h>
</screenRect>
<screenRect>
<x>600</x>
<y>0</y>
<w>600</w>
<h>1920</h>
</screenRect>
<!--
<screenRect>
<x>360</x>
<y>0</y>
<w>360</w>
<w>540</w>
<h>1200</h>
</screenRect>
-->
<pointSize>2.5</pointSize>
<lineWidth>1</lineWidth>
<xshift>0.0140476</xshift>
<yshift>0.0293333</yshift>
<xshift>0.0104762</xshift>
<yshift>0.0274286</yshift>
</settings>
19 changes: 10 additions & 9 deletions Renderer/bin/data/portraits.xml
@@ -1,5 +1,15 @@
<portraits>

<!-- ALICE -->
<portrait>
<name>alice</name>
<soundFile>Alice.aif</soundFile>
<close>
<mediaFolder>ALICE_CLOSE</mediaFolder>
</close>
</portrait>


<!-- MARK -->
<portrait>
<name>mark</name>
Expand All @@ -23,15 +33,6 @@
</studio>
</portrait>

<!-- ALICE -->
<portrait>
<name>alice</name>
<soundFile>Alice.aif</soundFile>
<close>
<mediaFolder>ALICE_CLOSE</mediaFolder>
</close>
</portrait>

<!-- JENNY -->
<portrait>
<name>jenny</name>
Expand Down
80 changes: 56 additions & 24 deletions Renderer/src/ScreenLabPortrait.cpp
Expand Up @@ -11,15 +11,20 @@
ScreenLabPortrait::ScreenLabPortrait(){
// startFrame = 0;
// endFrame = -1;
rendererRef = false;
rendererRef = NULL;
useHighResPlayer = false;
render = false;
}

void ScreenLabPortrait::setup(PortraitType _type, string mediaFolder, string soundPath){
type = _type;
cout << "Setting up portrait " << endl;

soundPlayer.loadMovie(soundPath);
soundPlayer.setLoopState(OF_LOOP_NONE);
cout << "media folder " << mediaFolder << " " << soundPath << endl;
if(take.loadFromFolder(mediaFolder)){
cout << "Low res video is " << take.lowResVideoPath << endl;
videoPlayer.loadMovie(take.lowResVideoPath);
// rendererRef->setTextureScale(640./1920, 360./1080);
//videoPlayer.loadMovie(take.hiResVideoPath);
Expand All @@ -29,6 +34,10 @@ void ScreenLabPortrait::setup(PortraitType _type, string mediaFolder, string sou
ofLogError("ScreenLabPortrait -- Pairings not ready!");
}

renderFolder = mediaFolder + "/renders";
if(!ofDirectory(renderFolder).exists()){
ofDirectory(renderFolder).create();
}
videoTimes = pairing.getStartAndEndTimes(videoPlayer, depthImages);

take.populateRenderSettings();
Expand All @@ -55,26 +64,41 @@ void ScreenLabPortrait::setup(PortraitType _type, string mediaFolder, string sou
void ScreenLabPortrait::resetAndPlay(){
lastTime = 0;

cout << "setting up sound player" << endl;

soundPlayer.setVolume(1300);
soundPlayer.setPosition(0);
soundPlayer.play();
soundPlayer.setLoopState(OF_LOOP_NONE);

rendererRef->setup(take.calibrationDirectory);

cout << "setting up renderer " << endl;
cout << "sound player duration " << soundPlayer.getDuration() << endl;

videoPlayer.setSpeed(.5);
//videoPlayer.setFrame(startFrame);
videoPlayer.setPosition(videoTimes.min / videoPlayer.getDuration() );
videoPlayer.setVolume(0);
videoPlayer.play();
videoPlayer.setLoopState(OF_LOOP_NORMAL);
if(useHighResPlayer){
if(!hiResPlayer.isLoaded()){
hiResPlayer.loadMovie(take.hiResVideoPath);
}
hiResPlayer.setSpeed(.5);
//videoPlayer.setFrame(startFrame);
hiResPlayer.setPosition(videoTimes.min / videoPlayer.getDuration() );
hiResPlayer.setVolume(0);
hiResPlayer.play();
hiResPlayer.setLoopState(OF_LOOP_NORMAL);
rendererRef->setRGBTexture(hiResPlayer);
}
else {
videoPlayer.setSpeed(.5);
//videoPlayer.setFrame(startFrame);
videoPlayer.setPosition(videoTimes.min / videoPlayer.getDuration() );
videoPlayer.setVolume(0);
videoPlayer.play();
videoPlayer.setLoopState(OF_LOOP_NORMAL);
rendererRef->setRGBTexture(videoPlayer);
}

rendererRef->setup(take.calibrationDirectory);
rendererRef->setRGBTexture(videoPlayer);
rendererRef->setDepthImage(depthImages.getPixels());
// if(take.getRenderSettings().size() != 0){
//take.getRenderSettings()[0].applyToRenderer(*rendererRef);
// }
rendererRef->farClip = 1200;
if(name == "jenny"){
rendererRef->farClip = 925;
Expand All @@ -84,8 +108,8 @@ void ScreenLabPortrait::resetAndPlay(){
}

if(name == "kev"){
rendererRef->xmult = 0.0140476;
rendererRef->ymult = 0.0293333;
rendererRef->xmult = 0.0104762;
rendererRef->ymult = 0.0274286;
}
else{
rendererRef->xmult = 0;
Expand All @@ -95,30 +119,38 @@ void ScreenLabPortrait::resetAndPlay(){
ofAddListener(ofEvents().update, this, &ScreenLabPortrait::update);
}

void ScreenLabPortrait::startRender(){
hiResPlayer.setSpeed(0);
render = true;
}

void ScreenLabPortrait::stop(){
cout << "stopping portraits " << endl;
videoPlayer.stop();
hiResPlayer.stop();
soundPlayer.stop();
ofRemoveListener(ofEvents().update, this, &ScreenLabPortrait::update);
cout << "portrait stopped" << endl;
}

void ScreenLabPortrait::update(ofEventArgs& args){
if(soundPlayer.getPosition() == 1.0 || lastTime > soundPlayer.getPosition()){ //looops?
if(!render && (soundPlayer.getPosition() == 1.0 || lastTime > soundPlayer.getPosition()) ){
stop();
}
lastTime = soundPlayer.getPosition();

videoPlayer.update();
if(videoPlayer.isFrameNew()){
if(videoPlayer.getPosition() >= videoTimes.max / videoPlayer.getDuration()){
videoPlayer.setFrame(videoTimes.min / videoPlayer.getDuration() );
ofVideoPlayer& player = useHighResPlayer ? hiResPlayer : videoPlayer;
if(render){
player.setFrame(player.getCurrentFrame()+1);
}
player.update();
if(player.isFrameNew()){
if(player.getPosition() >= videoTimes.max / player.getDuration()){
player.setPosition(videoTimes.min / player.getDuration() );
}
else {
long time = pairing.getDepthFrameForVideoFrame(videoPlayer.getPosition() * videoPlayer.getDuration() * 1000);
long time = pairing.getDepthFrameForVideoFrame(player.getPosition() * player.getDuration() * 1000);
depthImages.selectTime( time );
//ofShortPixels& pix = depthImages.getPixels();
//filler.close(pix);
filler.close(depthImages.getPixels());
// rendererRef->setDepthImage(pix);
rendererRef->update();
}
}
Expand Down
7 changes: 6 additions & 1 deletion Renderer/src/ScreenLabPortrait.h
Expand Up @@ -42,9 +42,14 @@ class ScreenLabPortrait {
ofxDepthImageSequence depthImages;
ofxRGBDVideoDepthSequence pairing;

bool useHighResPlayer;
PortraitType type;
ofVideoPlayer videoPlayer;
ofVideoPlayer hiResPlayer;
ofVideoPlayer soundPlayer;
ofxDepthHoleFiller filler;


string renderFolder;
void startRender();
bool render;
};

0 comments on commit 1419b16

Please sign in to comment.