16#include <cvb/device_factory.hpp>
17#include <cvb/image.hpp>
18#include <cvb/global.hpp>
22static const constexpr int NUM_ELEMENTS_TO_ACQUIRE = 10;
27int main(
int argc,
char* argv[])
32 bool demonstrateWithMock =
33 ((argc > 1) && (
std::string(argv[1]).find(
"--mock") != std::string::npos)) ? true :
false;
36 auto discoverFlags = Cvb::DiscoverFlags::IgnoreVins;
39 if (demonstrateWithMock)
40 discoverFlags |= Cvb::DiscoverFlags::IncludeMockTL;
52 if (demonstrateWithMock)
54 for (
auto n = 0; (n < infoList.size()) && accessToken.empty(); ++n)
55 if (infoList.at(n).AccessToken().find(
"MockTL") != std::string::npos)
56 accessToken = infoList.at(n).AccessToken();
59 if (accessToken.empty())
63 accessToken = infoList.front().AccessToken();
67 Cvb::DeviceFactory::Open<Cvb::GenICamDevice>(infoList.front().AccessToken(), Cvb::AcquisitionStack::GenTL);
71 std::generate_n(std::back_inserter(streams), device->StreamCount(),
72 [&device, i = 0]()
mutable { return device->Stream<Cvb::ImageStream>(i++); });
73 std::cout <<
"Stream count: " << streams.size() <<
"\n";
76 for (
const auto stream : streams)
82 for (
auto imageIndex = 0; imageIndex < NUM_ELEMENTS_TO_ACQUIRE; ++imageIndex)
84 for (
auto streamIndex = 0u; streamIndex < streams.size(); ++streamIndex)
86 const auto stream = streams[streamIndex];
87 auto [image, waitStatus, nodeMaps] = stream->WaitFor(TIMEOUT);
96 std::cout <<
"Wait status not OK: " << WAIT_ERROR_STATES[waitStatus] <<
"\n";
103 std::cout <<
"Stream #" << streamIndex <<
", Image #" << imageIndex;
104 std::cout << std::hex <<
", Width: " << image->Width() <<
105 ", Height: " << image->Height() <<
"\n";
110 for (
const auto stream : streams)
static std::vector< DiscoveryInformation > Discover()
Discovers available devices (not vins) with a default time span of 300ms.
Definition: decl_device_factory.hpp:221
@ Abort
The acquisition has been stopped asynchronously, there is no image buffer.
@ Ok
Everything is fine, a new image arrived.
@ Timeout
A timeout occurred, no image buffer has been returned.