Browse Source

Add `CameraSource` example

Based on thoughts about making the addon as lighweight as possible. One of possible future steps - do the same with video and image sources, leaving more space for user interface related issues.
master
Krisjanis Rijnieks 9 years ago
parent
commit
449838d04c
  1. 13
      example-camera/Makefile
  2. 17
      example-camera/Project.xcconfig
  3. 4
      example-camera/addons.make
  4. 4
      example-camera/bin/.gitignore
  5. 36
      example-camera/bin/data/defaultSurfaces.xml
  6. 1349
      example-camera/example-camera.xcodeproj/project.pbxproj
  7. 7
      example-camera/example-camera.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  8. 30
      example-camera/example-camera.xcodeproj/project.xcworkspace/xcshareddata/example-camera.xcscmblueprint
  9. 30
      example-camera/example-camera.xcodeproj/project.xcworkspace/xcshareddata/example.xcscmblueprint
  10. BIN
      example-camera/example-camera.xcodeproj/project.xcworkspace/xcuserdata/kr15h.xcuserdatad/UserInterfaceState.xcuserstate
  11. 91
      example-camera/example-camera.xcodeproj/xcshareddata/xcschemes/example-camera Debug.xcscheme
  12. 91
      example-camera/example-camera.xcodeproj/xcshareddata/xcschemes/example-camera Release.xcscheme
  13. 27
      example-camera/example-camera.xcodeproj/xcuserdata/kr15h.xcuserdatad/xcschemes/xcschememanagement.plist
  14. 22
      example-camera/openFrameworks-Info.plist
  15. 45
      example-camera/src/CameraSource.cpp
  16. 24
      example-camera/src/CameraSource.h
  17. 24
      example-camera/src/main.cpp
  18. 12
      example-camera/src/ofApp.cpp
  19. 21
      example-camera/src/ofApp.h

13
example-camera/Makefile

@ -0,0 +1,13 @@
# Attempt to load a config.make file.
# If none is found, project defaults in config.project.make will be used.
ifneq ($(wildcard config.make),)
include config.make
endif
# make sure the the OF_ROOT location is defined
ifndef OF_ROOT
OF_ROOT=$(realpath ../../..)
endif
# call the project makefile!
include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk

17
example-camera/Project.xcconfig

@ -0,0 +1,17 @@
//THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT.
//THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED
OF_PATH = ../../..
//THIS HAS ALL THE HEADER AND LIBS FOR OF CORE
#include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig"
//ICONS - NEW IN 0072
ICON_NAME_DEBUG = icon-debug.icns
ICON_NAME_RELEASE = icon.icns
ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
//IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
//ICON_FILE_PATH = bin/data/
OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)

4
example-camera/addons.make

@ -0,0 +1,4 @@
ofxPiMapper
ofxIO
ofxXmlSettings
ofxGui

4
example-camera/bin/.gitignore

@ -0,0 +1,4 @@
*.app
data/*.jpg
data/settings.xml
data/surfaces.xml

36
example-camera/bin/data/defaultSurfaces.xml

@ -0,0 +1,36 @@
<surfaces>
<surface>
<vertices>
<vertex>
<x>415.000000000</x>
<y>51.000000000</y>
</vertex>
<vertex>
<x>581.000000000</x>
<y>388.000000000</y>
</vertex>
<vertex>
<x>183.000000000</x>
<y>357.000000000</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.556249976</x>
<y>0.108333334</y>
</texCoord>
<texCoord>
<x>0.862500012</x>
<y>0.941666663</y>
</texCoord>
<texCoord>
<x>0.118749999</x>
<y>0.862500012</y>
</texCoord>
</texCoords>
<source>
<source-type>fbo</source-type>
<source-name>Camera Source</source-name>
</source>
</surface>
</surfaces>

1349
example-camera/example-camera.xcodeproj/project.pbxproj

File diff suppressed because it is too large

7
example-camera/example-camera.xcodeproj/project.xcworkspace/contents.xcworkspacedata

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:/Users/kr15h/Development/openFrameworks/of_v0.9.0_osx_release/addons/ofxPiMapper/example-camera/example-camera.xcodeproj">
</FileRef>
</Workspace>

30
example-camera/example-camera.xcodeproj/project.xcworkspace/xcshareddata/example-camera.xcscmblueprint

@ -0,0 +1,30 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "F18B6FEBE66912B859D879DB0D93A2398D3668F4",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"CA29DB320F881B85D76220FC5498A4D1FA4F037C" : 0,
"F18B6FEBE66912B859D879DB0D93A2398D3668F4" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "DD202D43-228A-426A-87F1-93F098EBC593",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"CA29DB320F881B85D76220FC5498A4D1FA4F037C" : "ofxIO\/",
"F18B6FEBE66912B859D879DB0D93A2398D3668F4" : "ofxPiMapper\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "example-camera",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "example-camera\/example-camera.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/bakercp\/ofxIO.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "CA29DB320F881B85D76220FC5498A4D1FA4F037C"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/kr15h\/ofxPiMapper.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "F18B6FEBE66912B859D879DB0D93A2398D3668F4"
}
]
}

30
example-camera/example-camera.xcodeproj/project.xcworkspace/xcshareddata/example.xcscmblueprint

@ -0,0 +1,30 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "F18B6FEBE66912B859D879DB0D93A2398D3668F4",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"CA29DB320F881B85D76220FC5498A4D1FA4F037C" : 0,
"F18B6FEBE66912B859D879DB0D93A2398D3668F4" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "7BBBCBAC-9A41-4C8B-9A6B-DE741AB94199",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"CA29DB320F881B85D76220FC5498A4D1FA4F037C" : "ofxIO\/",
"F18B6FEBE66912B859D879DB0D93A2398D3668F4" : "ofxPiMapper\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "example",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "example-camera\/example.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/bakercp\/ofxIO.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "CA29DB320F881B85D76220FC5498A4D1FA4F037C"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/kr15h\/ofxPiMapper.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "F18B6FEBE66912B859D879DB0D93A2398D3668F4"
}
]
}

BIN
example-camera/example-camera.xcodeproj/project.xcworkspace/xcuserdata/kr15h.xcuserdatad/UserInterfaceState.xcuserstate

Binary file not shown.

91
example-camera/example-camera.xcodeproj/xcshareddata/xcschemes/example-camera Debug.xcscheme

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example.app"
BlueprintName = "example-camera"
ReferencedContainer = "container:example-camera.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example.app"
BlueprintName = "example-camera"
ReferencedContainer = "container:example-camera.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example.app"
BlueprintName = "example-camera"
ReferencedContainer = "container:example-camera.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Debug"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example.app"
BlueprintName = "example-camera"
ReferencedContainer = "container:example-camera.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Debug"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

91
example-camera/example-camera.xcodeproj/xcshareddata/xcschemes/example-camera Release.xcscheme

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example.app"
BlueprintName = "example-camera"
ReferencedContainer = "container:example-camera.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example.app"
BlueprintName = "example-camera"
ReferencedContainer = "container:example-camera.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example.app"
BlueprintName = "example-camera"
ReferencedContainer = "container:example-camera.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example.app"
BlueprintName = "example-camera"
ReferencedContainer = "container:example-camera.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Release">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

27
example-camera/example-camera.xcodeproj/xcuserdata/kr15h.xcuserdatad/xcschemes/xcschememanagement.plist

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>example-camera Debug.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>example-camera Release.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>E4B69B5A0A3A1756003C02F2</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

22
example-camera/openFrameworks-Info.plist

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>${ICON}</string>
<key>CFBundleIdentifier</key>
<string>cc.openFrameworks.ofapp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>

45
example-camera/src/CameraSource.cpp

@ -0,0 +1,45 @@
#include "CameraSource.h"
CameraSource::CameraSource(){
name = "Camera Source";
_cameraWidth = 320;
_cameraHeight = 240;
vector<ofVideoDevice> devices = _videoGrabber.listDevices();
_cameraFound = false;
for(int i = 0; i < devices.size(); i++){
if(devices[i].bAvailable){
ofLogNotice() << devices[i].id << ": " << devices[i].deviceName;
_cameraFound = true;
break;
}
}
if(_cameraFound){
_videoGrabber.setDeviceID(0);
_videoGrabber.setup(_cameraWidth, _cameraHeight);
}
allocate(_cameraWidth, _cameraHeight);
}
void CameraSource::update(){
if(_videoGrabber.isInitialized()){
_videoGrabber.update();
}
}
void CameraSource::draw(){
ofClear(0);
ofSetHexColor(0xffffff);
if(_videoGrabber.isInitialized()){
ofDisableNormalizedTexCoords();
_videoGrabber.draw(0, 0);
ofEnableNormalizedTexCoords();
}else{
ofDrawBitmapString("no camera", _cameraWidth / 2.0f - 40.0f, _cameraHeight / 2.0f + 10.0f);
}
}

24
example-camera/src/CameraSource.h

@ -0,0 +1,24 @@
/*
* CameraSource
* Camera source for ofxPiMapper
* Created by Krisjanis Rijnieks on 25/01/2016
*/
#pragma once
#include "ofMain.h"
#include "FboSource.h"
class CameraSource : public ofx::piMapper::FboSource {
public:
CameraSource();
void update();
void draw();
private:
ofVideoGrabber _videoGrabber;
int _cameraWidth;
int _cameraHeight;
bool _cameraFound;
};

24
example-camera/src/main.cpp

@ -0,0 +1,24 @@
#include "ofMain.h"
#include "ofApp.h"
#include <string>
#include <vector>
int main(int argc, char * argv[]){
bool fullscreen = false;
vector<string> arguments = vector<string>(argv, argv + argc);
for(int i = 0; i < arguments.size(); ++i){
if(arguments.at(i) == "-f"){
fullscreen = true;
break;
}
}
if(fullscreen){
ofSetupOpenGL(800, 450, OF_FULLSCREEN);
}else{
ofSetupOpenGL(800, 450, OF_WINDOW);
}
ofRunApp(new ofApp());
}

12
example-camera/src/ofApp.cpp

@ -0,0 +1,12 @@
#include "ofApp.h"
void ofApp::setup(){
ofBackground(0);
cameraSource = new CameraSource();
piMapper.registerFboSource(*cameraSource);
piMapper.setup();
}
void ofApp::draw(){
piMapper.draw();
}

21
example-camera/src/ofApp.h

@ -0,0 +1,21 @@
/*
* CameraSource example
* Based on the thought that ofxPiMapper should be as bare-bones as possible, thus all the source
* type functionality should come from outside.
* Created by Krisjanis Rijnieks on 25/01/2016
*/
#pragma once
#include "ofMain.h"
#include "ofxPiMapper.h"
#include "CameraSource.h"
class ofApp : public ofBaseApp {
public:
void setup();
void draw();
ofxPiMapper piMapper;
CameraSource * cameraSource;
};
Loading…
Cancel
Save