void PointGreyCamera::setupGigEPacketDelay(PGRGuid & guid, unsigned int packet_delay)
{
  GigECamera cam;
  Error error;
  error = cam.Connect(&guid);
  PointGreyCamera::handleError("PointGreyCamera::connect could not connect as GigE camera", error);
  GigEProperty prop;
  prop.propType = PACKET_DELAY;
  prop.value = packet_delay;
  error = cam.SetGigEProperty(&prop);
  PointGreyCamera::handleError("PointGreyCamera::connect could not set GigE packet_delay", error);
}
void PointGreyCamera::setupGigEPacketSize(PGRGuid & guid)
{
  GigECamera cam;
  Error error;
  error = cam.Connect(&guid);
  PointGreyCamera::handleError("PointGreyCamera::connect could not connect as GigE camera", error);
  unsigned int packet_size;
  error = cam.DiscoverGigEPacketSize(&packet_size);
  PointGreyCamera::handleError("PointGreyCamera::connect could not discover GigE packet_size", error);
  GigEProperty prop;
  prop.propType = PACKET_SIZE;
  error = cam.GetGigEProperty(&prop);
  PointGreyCamera::handleError("PointGreyCamera::connect could not get GigE packet_size", error);
  prop.value = packet_size;
  error = cam.SetGigEProperty(&prop);
  PointGreyCamera::handleError("PointGreyCamera::connect could not set GigE packet_size", error);
}
int RunSingleCamera( PGRGuid guid )
{
    const int k_numImages = 1000;

    Error error;
    GigECamera cam;

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

    // Connect to a camera
    error = cam.Connect(&guid);
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    // Get the camera information
    CameraInfo camInfo;
    error = cam.GetCameraInfo(&camInfo);
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    PrintCameraInfo(&camInfo);        

    unsigned int numStreamChannels = 0;
    error = cam.GetNumStreamChannels( &numStreamChannels );
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    for (unsigned int i=0; i < numStreamChannels; i++)
    {
        GigEStreamChannel streamChannel;
        error = cam.GetGigEStreamChannelInfo( i, &streamChannel );
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            return -1;
        }

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

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

    GigEImageSettingsInfo imageSettingsInfo;
    error = cam.GetGigEImageSettingsInfo( &imageSettingsInfo );
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

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

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

    error = cam.SetGigEImageSettings( &imageSettings );
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

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

    // Start capturing images
    error = cam.StartCapture();
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    Image rawImage;  
    Image convertedImage;
    for ( int imageCnt=0; imageCnt < k_numImages; imageCnt++ )
    {              
        // Retrieve an image
        error = cam.RetrieveBuffer( &rawImage );
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            continue;
        }

        printf( "Grabbed image %d\n", imageCnt );

        // Convert the raw image
        error = rawImage.Convert( PIXEL_FORMAT_RGBU, &convertedImage );
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            return -1;
        }  

        /*
        // Create a unique filename
        char filename[512];
        sprintf( filename, "GigEGrabEx-%u-%d.png", 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 = convertedImage.Save( filename );
        if (error != PGRERROR_OK)
        {
            PrintError( error );
            return -1;
        } 
        */
    }         

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

    // Stop capturing images
    error = cam.StopCapture();
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }      

    // Disconnect the camera
    error = cam.Disconnect();
    if (error != PGRERROR_OK)
    {
        PrintError( error );
        return -1;
    }

    return 0;
}
Ejemplo n.º 4
0
void CamInfoPage::SetCameraInformation( CameraInfo* pCamInfo )
{
    // Set the camera info labels
    char serial[64];
    if ( IsLadybug2() )
    {
        const unsigned int k_Ladybug2HeadReg = 0x1F80;

        Error error;
        unsigned int uiHeadNumber;
        error = m_pCamera->ReadRegister( k_Ladybug2HeadReg, &uiHeadNumber );
        if( error != PGRERROR_OK )
        {
            return;
        }
        sprintf ( serial, "%u(Head S/N.%u)", pCamInfo->serialNumber, uiHeadNumber );
    }
    else
    {
        sprintf( serial, "%u", pCamInfo->serialNumber );
    }

    char dcamVer[16];
    sprintf( dcamVer, "%1.2f", pCamInfo->iidcVer / 100.0f );

    m_pLabelSerial->set_text( serial );
    m_pLabelModel->set_text( pCamInfo->modelName );
    m_pLabelVendor->set_text( pCamInfo->vendorName );
    m_pLabelSensor->set_text( pCamInfo->sensorInfo );
    m_pLabelResolution->set_text( pCamInfo->sensorResolution );
    m_pLabelInterface->set_text( GetInterfaceString( pCamInfo->interfaceType ) );
    m_pLabelBusSpeed->set_text( GetBusSpeedString( pCamInfo->maximumBusSpeed ) );
    m_pLabelDCAMVer->set_text( dcamVer );
    m_pLabelFirmwareVer->set_text( pCamInfo->firmwareVersion );
    m_pLabelFirmwareBuildTime->set_text( pCamInfo->firmwareBuildTime );
    m_pLabelDriverName->set_text( pCamInfo->driverName );

    if ( pCamInfo->interfaceType == INTERFACE_GIGE )
    {
        m_pVboxGigECameraInfo->show();

        char gigEVersion[16];
        sprintf( gigEVersion, "%u.%u", pCamInfo->gigEMajorVersion, pCamInfo->gigEMinorVersion );
        m_pLabelGigEVersion->set_text( gigEVersion );

        m_pLabelGigEUserDefinedName->set_text( pCamInfo->userDefinedName );
        m_pLabelGigEXmlUrl1->set_text( pCamInfo->xmlURL1 );
        m_pLabelGigEXmlUrl2->set_text( pCamInfo->xmlURL2 );

        char macAddress[64];
        sprintf(
            macAddress,
            "%02X:%02X:%02X:%02X:%02X:%02X",
            pCamInfo->macAddress.octets[0],
            pCamInfo->macAddress.octets[1],
            pCamInfo->macAddress.octets[2],
            pCamInfo->macAddress.octets[3],
            pCamInfo->macAddress.octets[4],
            pCamInfo->macAddress.octets[5]);
        m_pLabelGigEMacAddress->set_text( macAddress );

        char ipAddress[32];
        sprintf(
            ipAddress,
            "%u.%u.%u.%u",
            pCamInfo->ipAddress.octets[0],
            pCamInfo->ipAddress.octets[1],
            pCamInfo->ipAddress.octets[2],
            pCamInfo->ipAddress.octets[3]);
        m_pLabelGigEIpAddress->set_text( ipAddress );

        char subnetMask[32];
        sprintf(
            subnetMask,
            "%u.%u.%u.%u",
            pCamInfo->subnetMask.octets[0],
            pCamInfo->subnetMask.octets[1],
            pCamInfo->subnetMask.octets[2],
            pCamInfo->subnetMask.octets[3]);
        m_pLabelGigESubnetMask->set_text( subnetMask );

        char defaultGateway[32];
        sprintf(
            defaultGateway,
            "%u.%u.%u.%u",
            pCamInfo->defaultGateway.octets[0],
            pCamInfo->defaultGateway.octets[1],
            pCamInfo->defaultGateway.octets[2],
            pCamInfo->defaultGateway.octets[3]);
        m_pLabelGigEDefaultGateway->set_text( defaultGateway );

        GigECamera* pCamera = dynamic_cast<GigECamera*>(m_pCamera);
        if ( pCamera != NULL )
        {
            unsigned int ipConfigurationVal = 0;
            Error error = pCamera->ReadGVCPRegister( 0x0010, &ipConfigurationVal );
            if ( error != PGRERROR_OK )
            {
                return;
            }

            m_pCheckGigEIpLLA->set_active( (ipConfigurationVal & 0x1) != 0 );
            m_pCheckGigEIpDHCP->set_active( (ipConfigurationVal & 0x2) != 0 );
            m_pCheckGigEIpPersistentIp->set_active( (ipConfigurationVal & 0x4) != 0 );
        }
        else
        {
            m_pCheckGigEIpLLA->set_active( false );
            m_pCheckGigEIpDHCP->set_active( false );
            m_pCheckGigEIpPersistentIp->set_active( false );
        }

        m_pCheckGigEIpLLA->set_sensitive( false );
        m_pCheckGigEIpDHCP->set_sensitive( false );
        m_pCheckGigEIpPersistentIp->set_sensitive( false );
    }
    else
    {
        m_pVboxGigECameraInfo->hide();
    }
}