
10. API USAGE INFORMATION
code le is part of the API source code release. Please refer to the API docu-
mentation for further information on using ImageTransfer.
#i n c l u d e <v i s i o n t r a n s f e r / deviceenumeration . h>
#i n c l u d e <v i s i o n t r a n s f e r / i m a g e t r a n s f e r . h>
#i n c l u d e <v i s i o n t r a n s f e r / imagepair . h>
#i n c l u d e <iostream>
#i n c l u d e <exception >
#i n c l u d e <s t d i o . h>
#i f d e f _MSC_VER
// Visual s t u d i o does not come with s n p r i n t f
#d e f i n e s n p r i n t f _snprintf_s
#e n d i f
using namespace
v i s i o n t r a n s f e r ;
i n t
main ( ) {
try
{
// Search f o r SceneScan d e v i c e s
DeviceEnumeration deviceEnum ;
DeviceEnumeration : : DeviceList d e v i c e s = deviceEnum . d i s c o v e r D e v i c e s ( ) ;
i f
( d e v i c e s . s i z e ( ) == 0) {
std : : cout <<
"No d e v i c e s d i s c o v e r e d ! "
<< std : : endl ;
return
−
1;
}
// Print d e v i c e s
std : : cout <<
" Discovered d e v i c e s : "
<< std : : endl ;
f o r
(
unsigned i n t
i = 0 ; i< d e v i c e s . s i z e ( ) ; i++) {
std : : cout << d e v i c e s [ i ] . t o S t r i n g ( ) << std : : endl ;
}
std : : cout << std : : endl ;
// Create an image t r a n s f e r o b j e c t that r e c e i v e s data from
// the f i r s t detected SceneScan
ImageTransfer imageTransfer ( d e v i c e s [ 0 ] ) ;
// Receive 100 images
f o r
(
i n t
i =0; i <100; i++) {
std : : cout <<
" Receiving image "
<< i << std : : endl ;
// Receive image
ImagePair imagePair ;
while
( ! imageTransfer . receiveImagePair ( imagePair ) ) {
// Keep on t r y i n g u n t i l r e c e p t i o n i s s u c c e s s f u l
}
// Write both images one a f t e r another
f o r
(
i n t
imageNumber = 0 ; imageNumber <=1; imag+) {
// Create PGM f i l e
char
fileName [ 1 0 0 ] ;
s n p r i n t f ( fileName ,
s i z e o f
( fileName ) ,
"image%03d_%d . pgm"
, i ,
42