Subversion Repositories seema-scanner

Rev

Rev 3 | Rev 74 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 28
Line 7... Line 7...
7
// The class that we are interfacing to
7
// The class that we are interfacing to
8
#include "Camera.h"
8
#include "Camera.h"
9
 
9
 
10
using namespace std;
10
using namespace std;
11
 
11
 
12
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
12
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
-
 
13
    
-
 
14
    mexPrintf("nlhs: %d , nrhs: %d\n", nlhs, nrhs);
13
{	
15
    
14
    // Get the command string
16
    // Get the command string
15
    char cmd[64];
17
    char cmd[64];
16
	if (nrhs < 1 || mxGetString(prhs[0], cmd, sizeof(cmd)))
18
	if (nrhs < 1 || mxGetString(prhs[0], cmd, sizeof(cmd)))
17
		mexErrMsgTxt("First input should be a command string less than 64 characters long.");
19
		mexErrMsgTxt("First input should be a command string less than 64 characters long.");
18
    
20
    
Line 44... Line 46...
44
    if (!strcmp("NewCamera", cmd)) {
46
    if (!strcmp("NewCamera", cmd)) {
45
        // Check parameters
47
        // Check parameters
46
        if (nlhs != 1)
48
        if (nlhs != 1)
47
            mexErrMsgTxt("newCamera: One output expected.");
49
            mexErrMsgTxt("newCamera: One output expected.");
48
        if (nrhs < 3)
50
        if (nrhs < 3)
49
            mexErrMsgTxt("newCamera: Expected interface and screen number argument.");
51
            mexErrMsgTxt("newCamera: Expected interface and camera number argument.");
50
        unsigned int interfaceNum = (unsigned int)mxGetScalar(prhs[1]);
52
        unsigned int interfaceNum = (unsigned int)mxGetScalar(prhs[1]);
51
        unsigned int camNum = (unsigned int)mxGetScalar(prhs[2]);
53
        unsigned int camNum = (unsigned int)mxGetScalar(prhs[2]);
52
        // Return a handle to a new C++ instance
54
        // Return a handle to a new C++ instance
53
        plhs[0] = convertPtr2Mat<Camera>(Camera::NewCamera(interfaceNum, camNum));
55
        plhs[0] = convertPtr2Mat<Camera>(Camera::NewCamera(interfaceNum, camNum, triggerModeSoftware));
54
        return;
56
        return;
55
    }
57
    }
56
    
58
    
57
    // Class methods
59
    // Class methods
58
    // Check if there is a second input, which should be the class instance handle
60
    // Check if there is a second input, which should be the class instance handle
Line 70... Line 72...
70
    }
72
    }
71
    
73
    
72
    // Get the class instance pointer from the second input
74
    // Get the class instance pointer from the second input
73
    Camera *Camera_instance = convertMat2Ptr<Camera>(prhs[1]);
75
    Camera *Camera_instance = convertMat2Ptr<Camera>(prhs[1]);
74
    
76
    
-
 
77
	// Call the various class methods
-
 
78
    // startCapture
-
 
79
    if (!strcmp("startCapture", cmd)) {
-
 
80
        // Check parameters
-
 
81
        if (nlhs > 0 || nrhs > 2)
-
 
82
            mexErrMsgTxt("startCapture: Unexpected arguments.");
-
 
83
        // Call the method
-
 
84
        Camera_instance->startCapture();
-
 
85
        return;
-
 
86
    }
-
 
87
    
-
 
88
	// Call the various class methods
-
 
89
    // stopCapture
-
 
90
    if (!strcmp("stopCapture", cmd)) {
-
 
91
        // Check parameters
-
 
92
        if (nlhs > 0 || nrhs > 2)
-
 
93
            mexErrMsgTxt("stopCapture: Unexpected arguments.");
-
 
94
        // Call the method
-
 
95
        Camera_instance->stopCapture();
-
 
96
        return;
-
 
97
    }
-
 
98
    
-
 
99
	// trigger
-
 
100
    if (!strcmp("trigger", cmd)) {
-
 
101
        // Check parameters
-
 
102
        if (nlhs > 0 || nrhs > 2)
-
 
103
            mexErrMsgTxt("trigger: Unexpected arguments.");
-
 
104
        // Call the method
-
 
105
        Camera_instance->trigger();
-
 
106
        return;
-
 
107
    }
-
 
108
    
75
    // Call the various class methods
109
    // Call the various class methods
76
    // getSingleFrame
110
    // getFrame
77
    if (!strcmp("getSingleFrame", cmd)) {
111
    if (!strcmp("getFrame", cmd)) {
78
        // Check parameters
112
        // Check parameters
79
        if (nlhs < 1 || nrhs > 2)
113
        if (nlhs < 1 || nrhs > 2)
80
            mexErrMsgTxt("getSingleFrame: Unexpected arguments.");
114
            mexErrMsgTxt("getFrame: Unexpected arguments.");
81
        // Call the method
115
        // Call the method
82
        CameraFrame frame = Camera_instance->getSingleFrame();
116
        CameraFrame frame = Camera_instance->getFrame();
-
 
117
        // receive frame data in permuted dimensional order
-
 
118
        int dims[] = {frame.channels, frame.width, frame.height};
83
        plhs[0] = mxCreateNumericMatrix(frame.width, frame.height, mxUINT8_CLASS, mxREAL);
119
        plhs[0] = mxCreateNumericArray(3, dims, mxUINT8_CLASS, mxREAL);
84
        memcpy(mxGetData(plhs[0]), frame.memory, frame.height*frame.width);
120
        memcpy(mxGetData(plhs[0]), frame.memory, frame.height*frame.width*frame.channels);
85
        //Camera_instance->unlockFrame();
-
 
86
        return;
121
        return;
87
    }
122
    }
88
//    // Test
-
 
89
//    if (!strcmp("test", cmd)) {
-
 
90
//        // Check parameters
-
 
91
//        if (nlhs < 0 || nrhs < 2)
-
 
92
//            mexErrMsgTxt("Test: Unexpected arguments.");
-
 
93
//        // Call the method
-
 
94
//        PatternProjector_instance->test();
-
 
95
//        return;
-
 
96
//    }
-
 
97
    
123
    
98
    // Got here, so command not recognized
124
    // Got here, so command not recognized
99
    mexErrMsgTxt("Command not recognized.");
125
    mexErrMsgTxt("Command not recognized.");
100
}
126
}