Exemple #1
0
FC2_Camera_Information FC2_Camera__information_get(FC2_Camera camera) {
    FC2_Camera_Information camera_information =
      Memory__new(FC2_Camera_Information);
    FC2_Error error = fc2GetCameraInfo(camera, camera_information);
    assert (error == FC2_ERROR_OK);
    return camera_information;
}
Exemple #2
0
void AssignName(fc2Context context, char *name) 
{
  fc2CameraInfo camInfo;
  check_point_grey(fc2GetCameraInfo(context, &camInfo));
  sprintf(name, "Camera_%d_", camInfo.serialNumber);
  //  printf("Identified: %s\n",name);
}
Exemple #3
0
void PrintCameraInfo( fc2Context context )
{
  fc2Error error;
  fc2CameraInfo camInfo;
  error = fc2GetCameraInfo( context, &camInfo );
  if ( error != FC2_ERROR_OK )
  {
    // Error
  }
  
  printf("\n*** CAMERA INFORMATION ***\n"
	 "Serial number - %u\n"
	 "Camera model - %s\n"
	 "Camera vendor - %s\n"
	 "Sensor - %s\n"
	 "Resolution - %s\n"
	 "Firmware version - %s\n"
	 "Firmware build time - %s\n\n",
	 camInfo.serialNumber,
	 camInfo.modelName,
	 camInfo.vendorName,
	 camInfo.sensorInfo,
	 camInfo.sensorResolution,
	 camInfo.firmwareVersion,
	 camInfo.firmwareBuildTime );
}
Exemple #4
0
//
// idlpgr_GetCameraInfo
//
// Returns a subset of the fc2CameraInfo structure
//
IDL_VPTR IDL_CDECL idlpgr_GetCameraInfo(int argc, IDL_VPTR argv[])
{
  fc2Error error;
  fc2Context context;
  fc2CameraInfo camerainfo;
  IDL_StructDefPtr sdef;
  char *pd;
  IDL_MEMINT one = 1;
  IDL_VPTR idl_camerainfo;

  context = (fc2Context) IDL_ULong64Scalar(argv[0]);

  error = fc2GetCameraInfo(context, &camerainfo);
  if (error) 
    IDL_MessageFromBlock(msgs, M_IDLPGR_ERRORCODE, IDL_MSG_LONGJMP,
			 "Could not read camera info",
			 error);

  static IDL_STRUCT_TAG_DEF tags[] = {
    { "SERIALNUMBER",     0, (void *) IDL_TYP_ULONG },
    { "ISCOLORCAMERA",    0, (void *) IDL_TYP_LONG },
    { "MODELNAME",        0, (void *) IDL_TYP_STRING },
    { "VENDORNAME",       0, (void *) IDL_TYP_STRING },
    { "SENSORINFO",       0, (void *) IDL_TYP_STRING },
    { "SENSORRESOLUTION", 0, (void *) IDL_TYP_STRING },
    { "DRIVERNAME",       0, (void *) IDL_TYP_STRING },
    { "FIRMWAREVERSION",  0, (void *) IDL_TYP_STRING },
    { 0 }
  };
  sdef = IDL_MakeStruct("fc2CameraInfo", tags);
  pd = IDL_MakeTempStruct(sdef, 1, &one, &idl_camerainfo, TRUE);
  *(IDL_ULONG *) pd      = camerainfo.serialNumber;
  pd += sizeof(IDL_ULONG);
  *(IDL_LONG *) pd = camerainfo.isColorCamera;
  pd += sizeof(IDL_LONG);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.modelName);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.vendorName);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.sensorInfo);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.sensorResolution);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.driverName);
  pd += sizeof(IDL_STRING);
  IDL_StrStore((IDL_STRING *) pd, camerainfo.firmwareVersion);
  
  return idl_camerainfo;
}
int RunSingleCamera( fc2Context context, fc2PGRGuid guid)
{
    const int k_numImages = 1000;

    fc2Error error;
    fc2CameraInfo camInfo;
    unsigned int numStreamChannels = 0;
    fc2GigEImageSettingsInfo imageSettingsInfo;
    fc2Image rawImage, convertedImage;    
    fc2GigEImageSettings imageSettings;
    int imageCnt;
    unsigned int i;
    char filename[512];

    printf( "Connecting to camera...\n" );

    // Connect to a camera
    error = fc2Connect( context, &guid );
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2Connect: %s\n", fc2ErrorToDescription(error) );
        return -1;
    }

    // Get the camera information
    error = fc2GetCameraInfo( context, &camInfo);
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2GetCameraInfo: %s\n", fc2ErrorToDescription(error) );
        return -1;
    }

    PrintCameraInfo(&camInfo);        

    error = fc2GetNumStreamChannels( context, &numStreamChannels );
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2GetNumStreamChannels: %s\n", fc2ErrorToDescription(error) );
        return -1;
    }

    for ( i = 0; i < numStreamChannels; i++)
    {
        fc2GigEStreamChannel streamChannel;
        error = fc2GetGigEStreamChannelInfo( context, i, &streamChannel );
        if ( error != FC2_ERROR_OK )
        {
            printf( "Error in fc2GetGigEStreamChannelInfo: %s\n", fc2ErrorToDescription(error) );
            return -1;
        }

        printf( "\nPrinting stream channel information for channel %u:\n", i );
        PrintStreamChannelInfo( &streamChannel );
    }    

    printf( "Querying GigE image setting information...\n" );

    error = fc2GetGigEImageSettingsInfo( context, &imageSettingsInfo );
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2GetGigEImageSettingsInfo: %s\n", fc2ErrorToDescription(error) );
        return -1;
    }

    imageSettings.offsetX = 0;
    imageSettings.offsetY = 0;
    imageSettings.height = imageSettingsInfo.maxHeight;
    imageSettings.width = imageSettingsInfo.maxWidth;
    imageSettings.pixelFormat = FC2_PIXEL_FORMAT_MONO8;

    printf( "Setting GigE image settings...\n" );

    error = fc2SetGigEImageSettings( context, &imageSettings );
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2SetGigEImageSettings: %s\n", fc2ErrorToDescription(error) );
        return -1;
    }

    printf( "Starting image capture...\n" );

    // Start capturing images
    error = fc2StartCapture( context);
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2StartCapture: %s\n", fc2ErrorToDescription(error) );
        return -1;
    }

    // Prepare images
    error = fc2CreateImage( &rawImage );
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2CreateImage: %s\n", fc2ErrorToDescription(error) );
        return -1;
    }

    error = fc2CreateImage( &convertedImage );
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2CreateImage: %s\n", fc2ErrorToDescription(error) );
        return -1;
    }

    for ( imageCnt=0; imageCnt < k_numImages; imageCnt++ )
    {              
        // Retrieve an image
        error = fc2RetrieveBuffer( context, &rawImage );
        if ( error != FC2_ERROR_OK )
        {
            printf( "Error in fc2RetrieveBuffer: %s\n", fc2ErrorToDescription(error) );
            return -1;
        }

        printf( "Grabbed image %d\n", imageCnt );
        
        // Convert the raw image
        error = fc2ConvertImageTo( FC2_PIXEL_FORMAT_MONO8, 
                                &rawImage,
                                &convertedImage );
        if ( error != FC2_ERROR_OK )
        {
            printf( "Error in fc2ConvertImage: %s\n", fc2ErrorToDescription(error) );
            return -1;
        }

        // Create a unique filename
        sprintf( filename, "GigEGrabEx-%u-%d.pgm", camInfo.serialNumber, imageCnt );

        /*
        // Save the image. If a file format is not passed in, then the file
        // extension is parsed to attempt to determine the file format.
        error = fc2SaveImage( &convertedImage, filename, FC2_PGM );
        if ( error != FC2_ERROR_OK )
        {
            printf( "Error in fc2SaveImage: %s\n", fc2ErrorToDescription(error) );
            return -1;
        }
        */
    }         

    printf( "Stopping capture...\n" );

    // Stop capturing images
    error = fc2StopCapture( context);
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2StopCapture: %s\n", fc2ErrorToDescription(error) );
    }

    // Disconnect the camera
    error = fc2Disconnect( context);
    if ( error != FC2_ERROR_OK )
    {
        printf( "Error in fc2Disconnect: %s\n", fc2ErrorToDescription(error) );
    }

    error = fc2DestroyImage( &rawImage );
    error = fc2DestroyImage( &convertedImage );

    return 0;
}