SoftwareTrigger just works once during streaming

Hi,

I’m struggling with the SoftwareTrigger. I configured my cameras to be used with a SoftwareTrigger (TriggerMode “On”, TriggerSource “Software”) and used the following code for testing purpose:

// Libraries 
#include <Windows.h> // To change process priority
#include <processthreadsapi.h>
#include <string>
#include <cstdint> //Fixed width integer types
#include <iostream>
#include <thread>
#include <cvb/image.hpp>
#include <cvb/device_factory.hpp> // To discover and open devices 
#include <cvb/async/single_stream_handler.hpp>
#include <cvb/async/async.hpp> // StreamHandlerGuard and singleStreamHandler
#include <cvb/driver/driver.hpp> // Stream, RingBuffer
#include <cvb/genapi/genapi.hpp> 

// Main program
int main()
{

	// Generate a List of all connected devices and get Model Name and Serial Number
	std::vector<Cvb::DiscoveryInformation> deviceList = Cvb::DeviceFactory::Discover();

	// Get device tokens
	std::vector<Cvb::String> devToken;
	for (const auto &device : deviceList)
	{
		devToken.emplace_back(device.AccessToken());
	}
	
	// open first device
	auto device = Cvb::DeviceFactory::Open(devToken.at(0));

	// Create a pointer which points to the NodeMap of the device.
	auto deviceNodeMap = device->NodeMap(CVB_LIT("Device"));
	
	// Get stream and start it
	Cvb::StreamPtr stream = device->Stream();
	stream->Start();

	// Define the softwareTrigger
	auto softwareTrigger = deviceNodeMap->Node<Cvb::CommandNode>(CVB_LIT("TriggerSoftware"));

	for (int i = 0; i < 10; ++i)
	{
		std::this_thread::sleep_for(std::chrono::seconds(2));
		// wait for an image with a timeout of 2 seconds
		softwareTrigger->Execute();
		Cvb::WaitResult<Cvb::StreamImage> waitResult = stream->WaitFor(std::chrono::seconds(5));
		if (waitResult.Status == Cvb::WaitStatus::Timeout)
			throw std::runtime_error("acquisition timeout");
		

		// Save file as bmp
		auto image = waitResult.Image;
		std::wstring s2 = L"image.bmp";
		auto filename = Cvb::String(s2);
		image->Save(filename);

		
		// get the timestamp of the image (usually a large integer number mapped to double - so better use fixed formatting)
		std::cout << "Acquired image... " << std::fixed << waitResult.Image->RawTimestamp() << std::endl;
	}
	// synchronously stop the stream
	stream->Stop();
	
	return 0;
}

In the second for loop cycle I always get a acquisition timeout and I can’t figure out why. Any ideas? I guess the SoftwareTrigger settings are correct, because in the first cycle the code saves an image.

Thanks for your Help!

Phil

Hi @pip

Please check if the Acquisition Mode of the camera is set to Continuous.
Maybe it’s on Single Frame mode? :slight_smile:

Thanks, that solved the problem!

1 Like