23
char *array;
/* The gateway routine */
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
const int dims[]= {4, 640, 480};
unsigned char *start_of_pr;
int bytes_to_copy;
double *x;
if(nrhs==1) { // if there is a parameter, close camera
freeMemory();
init = FALSE;
} else if(!init){ // if camera not initialized
if(!SelectDevice(0)){ //Select the first in the list (0)
mexErrMsgTxt("SelectDevice failed\n");
}
if(!NewDevice(CurDevInfo.Alias))
{
(void) OlImgCloseDevice(CurDevInfo.DevId);
mexErrMsgTxt("Init failed\n\nCamera might be
already open. Restart system, if necessary.\n");
}
init = TRUE;
mexPrintf("Camera initialized.\n");
}else{ // capture image
if(!AcquireToHost())
{
GlobalUnlock(hpAcquireBuf);
GlobalFree(hAcquireBuf);
(void)
OlImgCloseDevice(CurDevInfo.DevId);
mexErrMsgTxt("Acquire Failed\n");
}
/* Create a 4-by-640-by-480 array of unsigned
8-bit integers. */
plhs[0] =
mxCreateNumericArray(NDIMS,dims,mxUINT8_CLASS,mxREAL);
/* Populate the real part of the created array.
*/
start_of_pr = (unsigned char
*)mxGetData(plhs[0]);
bytes_to_copy = TOTAL_ELEMENTS *
mxGetElementSize(plhs[0]);
Comentários a estes Manuais