argument for exposure time

This commit is contained in:
Jan Grewe 2025-07-18 09:24:13 +02:00
parent 8da179cd6f
commit cbe9684564

View File

@ -39,11 +39,19 @@ uint32_t sensorHeight(CInstantCamera &camera) {
return maxheight.GetValue();
}
uint32_t sensorWidth(CInstantCamera &camera) {
CIntegerParameter maxwidth( camera.GetNodeMap(), "SensorWidth" );
return maxwidth.IsValid() && maxwidth.IsReadable() ? maxwidth.GetValue() : 0;
}
void exposureTime(CInstantCamera &camera, double exposure_time) {
GenApi::INodeMap& nodemap = camera.GetNodeMap();
CFloatParameter(nodemap, "ExposureTime").SetValue(exposure_time);
}
//void exposureTime(double exposure_time);
int main( int argc, char* argv[] ) {
@ -59,9 +67,10 @@ int main( int argc, char* argv[] ) {
int xOffset = 0;
int yOffset = 0;
int camIndex = 0;
double exposure_time = 10000;
string errorMessage = "";
String_t filename = "_TestVideo.mp4";
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if ((arg == "--help") || arg == "?"){
@ -72,6 +81,7 @@ int main( int argc, char* argv[] ) {
<< "\t --height|-h \t the image height in pixel, defaults to 2000\n"
<< "\t --xoffs|-x \t image x offset in pixel, defaults to 0\n"
<< "\t --yoffs|-y \t image y-offset in pixel, defaults to 0\n"
<< "\t --exposure|-e \t exposure time in us, defaults to 10000\n"
<< "\t --cameras|-c \t the desired number of cameras to grab at the same time, defaults to 1\n"
<< "\t --framecount|-n \t the number of frames, defaults to 100\n"
<< "\t --quality|-q \t the qualtiy of the compression (0 < q <= 100), defaults to 50\n"
@ -100,6 +110,9 @@ int main( int argc, char* argv[] ) {
if ((arg == "--yoffs" || arg == "-y") && i + 1 < argc) {
yOffset = std::atoi(argv[++i]);
}
if ((arg == "--exposure" || arg == "-e") && i + 1 < argc) {
exposure_time = std::atoi(argv[++i]);
}
if ((arg == "--index" || arg == "-i") && i + 1 < argc) {
camIndex = std::atoi(argv[++i]);
}
@ -157,13 +170,14 @@ int main( int argc, char* argv[] ) {
CEnumParameter pixelFormat( nodemap, "PixelFormat" );
CEnumParameter trigmode( nodemap, "TriggerMode");
CEnumParameter trigsource( nodemap, "TriggerSource");
exposureTime(cameras[i], exposure_time);
trigmode.TrySetValue( "On" );
trigsource.TrySetValue( "Software" );
width.TrySetValue( cWidth, IntegerValueCorrection_Nearest );
height.TrySetValue( cHeight, IntegerValueCorrection_Nearest );
offsetX.TrySetValue( xOffset, IntegerValueCorrection_Nearest );
offsetY.TrySetValue( yOffset, IntegerValueCorrection_Nearest );
}
CIntegerParameter width( cameras[0].GetNodeMap(), "Width" );
@ -236,6 +250,7 @@ int main( int argc, char* argv[] ) {
for ( int i =0; i < camCount; ++i ) {
success = success & frames[i]->GrabSucceeded();
}
if (success) {
if ( camCount > 1 ) {
leftImage.AttachGrabResultBuffer( frames[0] );
@ -248,7 +263,7 @@ int main( int argc, char* argv[] ) {
} else {
cout << "Error: " << std::hex << frames[0]->GetErrorCode() << std::dec << " " << frames[0]->GetErrorDescription() << endl;
}
counter += 1;
done = high_resolution_clock::now();
total_duration = duration_cast<microseconds>(done - before);