示例#1
0
文件: moveutil.c 项目: Limsik/e17
static void
endCamera(moveContext *context)
{
   cameraStop (0);

   cameraClose (0);
   cameraEnd ();

   sysMemContainerDestroy (context->camInfo.container);
}
示例#2
0
  void camera_eval(void *obj, int argc) {
    tCamera *camera = (tCamera *)obj;
    try {
      ystring_t func = ygets_q(argc-1);
      if(strcmp(func, "start")==0){
	long packetSize=8228;
	if(argc >1)  packetSize = ygets_l(argc-2);
	cameraStart(camera, packetSize);
	cameraSnap(camera);
      } else if(strcmp(func, "stop")==0){
	cameraStop(camera);
      } else if(strcmp(func, "getROI")==0){
	long dims[2]={1, 4};
	long *result = ypush_l(dims);
	tPvUint32 ROI[4];
	cameraGetROI(camera, ROI);
	for(int i=0;i<4;i++)  result[i] = ROI[i];
      } else if(strcmp(func, "setROI")==0){
	long ntot, dims;
	long *result = ygeta_l(argc-2, &ntot, &dims);
	tPvUint32 ROI[4];
	for(int i=0;i<4;i++) ROI[i]=result[i];
	cameraSetROI(camera, ROI);	
      } else if(strcmp(func, "getExpo")==0){
	tPvUint32 expo;
	cameraGetExpo(camera, &expo);
	ypush_long(expo);
     } else if(strcmp(func, "setExpo")==0){
	long expo = ygets_l(argc-2);
	cameraSetExpo(camera, expo);
      } else if(strcmp(func, "fastsnap")==0){
	long param = ygets_l(argc-2);
	unsigned long width = camera->Frame.Width;              // Image width
	unsigned long height= camera->Frame.Height;             // Image height
	long dims[4]={3, width, height, param};
	if(param ==1) dims[0]=2;
	char resValue[16];
	cameraGetPixelFormat(camera, resValue, 16);
	tPvFrame *buff = cameraSnap(camera, param);

	if(strcmp(resValue, "Mono8")==0) {
	  short *frame = ypush_s(dims);
	  for(long pose=0; pose<param; pose++){
	    unsigned char *src = (unsigned char *)buff[pose].ImageBuffer;
	    short *dst = &frame[pose*height*width];
	    for(unsigned long i=0; i<width*height; i++) {
	      dst[i] = src[i];
	    }
	  }
	} else if(strcmp(resValue, "Mono16")==0) {
	  int *frame = ypush_i(dims);
	  for(long pose=0; pose<param; pose++){
	    unsigned short *src = (unsigned short *)buff[pose].ImageBuffer;
	    int *dst = &frame[pose*height*width];
	    for(unsigned long i=0; i<width*height; i++) {
	      dst[i] = src[i];
	    }
	  }
	} else cout << "bad ppixel size !" << endl;
      } else if(strcmp(func, "snap")==0){
	long param = ygets_l(argc-2);
	unsigned long width = camera->Frame.Width;              // Image width
	unsigned long height= camera->Frame.Height;             // Image height
	long dims[4]={3, width, height, param};
	if(param ==1) dims[0]=2;
	char resValue[16];
	cameraGetPixelFormat(camera, resValue, 16);
	
	if(strcmp(resValue, "Mono8")==0) {
	  short *frame = ypush_s(dims);
	  for(long pose=0; pose<param; pose++){
	    cameraSnap(camera);
	    unsigned char *src = (unsigned char *)camera->Frame.ImageBuffer;
	    short *dst = &frame[pose*height*width];
	    for(unsigned long i=0; i<width*height; i++) {
	      dst[i] = src[i];
	    }
	  }
	} else if(strcmp(resValue, "Mono16")==0) {
	  int *frame = ypush_i(dims);
	  for(long pose=0; pose<param; pose++){
	    cameraSnap(camera);
	    unsigned short *src = (unsigned short *)camera->Frame.ImageBuffer;
	    int *dst = &frame[pose*height*width];
	    for(unsigned long i=0; i<width*height; i++) {
	      dst[i] = src[i];
	    }
	  }
	} else cout << "bad ppixel size !" << endl;
      } else cout << "F**K !" << endl;

    } catch ( string msg ) {
      y_error(msg.c_str());
    }
    catch ( char const * msg ) {
      y_error(msg);
    }
  }