root / branches / tbeta / Windows-PS3EyeMuticam / addons / ofxPS3 / src / ofxPS3.cpp @ 186

View | Annotate | Download (1.3 KB)

1
// Multicam version of PS3Eye fix
2
#include "ofxPS3.h"
3
#include <stdio.h>
4
5
unsigned int ofxPS3::camNum=0;
6
7
ofxPS3::ofxPS3() 
8
{
9
}
10
11
void ofxPS3::listDevices()
12
{
13
        // Enumerate the cameras on the bus.
14
        camNum = PS3EyeMulticamGetCameraCount();
15
         printf("\nFound %d PS3Eye camera(s)...\n", camNum);
16
}
17
18
PBYTE ofxPS3::getPixels()
19
{
20
        return pBuffer;
21
}
22
23
bool ofxPS3::isFrameNew()
24
{
25
        return PS3EyeMulticamGetFrame(pBuffer);
26
}
27
28
void ofxPS3::initPS3(int width,int height, int framerate)
29
{
30
        printf("selecting format...\n");
31
        PS3EyeMulticamOpen(camNum, width==640?VGA:QVGA, framerate);
32
        PS3EyeMulticamLoadSettings(".\\data\\multicam.xml");
33
        // get stitched image width
34
        PS3EyeMulticamGetFrameDimensions(camWidth, camHeight);
35
        // Allocate image buffer for grayscale image
36
        pBuffer = new BYTE[camWidth*camHeight];
37
        // Start capturing
38
        PS3EyeMulticamStart();
39
}
40
41
int ofxPS3::getDeviceCount()
42
{
43
        return PS3EyeMulticamGetCameraCount();
44
}
45
46
int ofxPS3::getCamWidth()
47
{
48
        return camWidth;
49
}
50
51
int ofxPS3::getCamHeight()
52
{
53
        return camHeight;
54
}
55
56
void ofxPS3::showSettings()
57
{
58
        PS3EyeMulticamShowSettings();
59
}
60
61
// Clean up
62
ofxPS3::~ofxPS3()
63
{
64
        // Stop capturing
65
        PS3EyeMulticamStop();
66
        Sleep(50);
67
        PS3EyeMulticamSaveSettings(".\\data\\multicam.xml");
68
        PS3EyeMulticamClose();
69
        delete [] pBuffer;
70
}