【初心者】 Java質問・相談スレ33 【大歓迎】

このエントリーをはてなブックマークに追加
541537
とりあえずソースのせます。のせていいのかわからんけど。
もしかしたらVCかもしれません。
長いんで分割します。
//PGRFlyCaptureTest.cpp
//=============================================================================
// System Includes
//=============================================================================
#include <assert.h>
#include <stdio.h>
#include <sys/timeb.h>

//=============================================================================
// Project Includes
//=============================================================================
#include "pgrflycapture.h"

int
main( int /* argc */, char* /* argv[] */ )
{
FlyCaptureErrorerror;
FlyCaptureContextcontext;

struct _timeb timeStart;
struct _timeb timeFinish;
542537:03/10/17 14:59
541の続き
// image returned by flycaptureGrabImage2().
FlyCaptureImage image;

//
// Initialize the image structure to sane values
//
image.iCols = 0;
image.iRows = 0;

// create the flycapture context.
error = flycaptureCreateContext( &context );
if( error != FLYCAPTURE_OK )
{
printf( "flycaptureCreateContext(): %s\n", flycaptureErrorToString( error ) );
getchar();
}

// enumerate the cameras on the bus
FlyCaptureInfo arInfo[ 32 ];
int iSize;
error = flycaptureBusEnumerateCameras( arInfo, &iSize );
if( error != FLYCAPTURE_OK )
{
printf( "flycaptureBusEnumerateCameras(): %s\n", flycaptureErrorToString( error ) );
getchar();
}
543537:03/10/17 15:00
542の続き
// initialize the first camera on the bus.
error = flycaptureInitialize( context, 0 );
if( error != FLYCAPTURE_OK )
{
printf( "flycaptureInitialize(): %s\n", flycaptureErrorToString( error ) );
getchar();
}

// start grabbing images in 8-bit greyscale 640x480 mode with a frame rate of 15
// fps.
error = flycaptureStart(
context,
FLYCAPTURE_VIDEOMODE_640x480Y8,
FLYCAPTURE_FRAMERATE_15 );
if( error != FLYCAPTURE_OK )
{
printf( "flycaptureStart(): %s\n", flycaptureErrorToString( error ) );
getchar();
}
544537:03/10/17 15:01
543の続き
// time the grabbing of 30 images.
_ftime( &timeStart );

for ( int i = 0; i < 30; i++ )
{
if( flycaptureGrabImage2( context, &image ) != FLYCAPTURE_OK )
{
printf( "Failed to grab image.\n" );
return false;
}
}

_ftime( &timeFinish );
printf( "It took %dms to grab %d images.\n",
( timeFinish.time * 1000 + timeFinish.millitm ) -
( timeStart.time * 1000 + timeStart.millitm ), i );
545537:03/10/17 15:02
544の続き
//
// Save last image to a .ppm.
//

//
// Convert the image to BGR24 for flycaptureWritePPM().
//
unsigned char* pimageBGR24 =
new unsigned char[ image.iCols * image.iRows * 3 ];

if( ::flycaptureConvertToBGR24( &image, pimageBGR24 ) == FLYCAPTURE_OK )
{
//
// Write out the image.
//
::flycaptureWritePPM(
pimageBGR24,
image.iRows,
image.iCols,
"image.ppm" );
}

delete [] pimageBGR24;
546537:03/10/17 15:02
544の続き
//
// destroy the context
//
error = flycaptureDestroyContext( context );
if( error != FLYCAPTURE_OK )
{
printf( "flycaptureDestroyContext: %s\n", flycaptureErrorToString( error ) );
}

printf( "Done! (hit enter)" );
getchar();
return 0;
}