libvisiontransfer  10.6.0
software_trigger_example.cpp
1 /*******************************************************************************
2  * Copyright (c) 2023 Allied Vision Technologies GmbH
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *******************************************************************************/
14 
15 #include <visiontransfer/deviceenumeration.h>
16 #include <visiontransfer/deviceparameters.h>
17 #include <iostream>
18 #include <exception>
19 #include <stdio.h>
20 
21 using namespace visiontransfer;
22 
23 int main(int, char**) {
24  try {
25  // Search for Nerian stereo devices
26  DeviceEnumeration deviceEnum;
27 
28  DeviceEnumeration::DeviceList devices = deviceEnum.discoverDevices();
29  if(devices.size() == 0) {
30  std::cout << "No devices discovered!" << std::endl;
31  return -1;
32  }
33 
34  // Print devices
35  std::cout << "Discovered devices:" << std::endl;
36  for(unsigned int i = 0; i< devices.size(); i++) {
37  std::cout << devices[i].toString() << std::endl;
38  }
39  std::cout << std::endl;
40 
41  // Create an image transfer object that receives data from
42  // the first detected Nerian stereo device
43  DeviceParameters parameters(devices[0]);
44 
45  // Send a software trigger request - this is only meaningful
46  // if External Trigger is set to Software (via the settings
47  // page Advanced Trigger / Pairing)
48  std::cout << "Sending software trigger request..." << std::endl;
49  parameters.triggerNow();
50 
51  std::cout << "Done." << std::endl;
52 
53  return 0;
54  } catch(const std::exception& ex) {
55  std::cerr << "Exception occurred: " << ex.what() << std::endl;
56  }
57 
58  return 0;
59 }
60 
DeviceList discoverDevices()
Discovers new devices and returns the list of all devices that have been found.
Allows for configuration of the parameters of a Nerian stereo device through a network connection...
Allows for the discovery of devices in the network.
Allied Vision