
10. API USAGE INFORMATION
imageNumber ) ;
imagePair . writePgmFile ( imageNumber , fileName ) ;
}
}
}
catch
(
const
std : : exception& ex ) {
std : : c e r r <<
" Exception occurred : "
<< ex . what ( ) << std : : endl ;
}
return
0 ;
}
10.3 AsyncTransfer Example
An example for using the class AsyncTransfer to receive processing results
over the network, and writing them to image les, is shown below. This source
code le is part of the API source code release. Please refer to the API docu-
mentation for further information on using AsyncTransfer.
#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 / a s y n c 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
43