Compare commits
2 Commits
8da179cd6f
...
4a8602bb42
Author | SHA1 | Date | |
---|---|---|---|
4a8602bb42 | |||
cbe9684564 |
@ -34,17 +34,32 @@ typedef high_resolution_clock Time;
|
|||||||
typedef milliseconds ms;
|
typedef milliseconds ms;
|
||||||
typedef duration<float> fsec;
|
typedef duration<float> fsec;
|
||||||
|
|
||||||
|
|
||||||
uint32_t sensorHeight(CInstantCamera &camera) {
|
uint32_t sensorHeight(CInstantCamera &camera) {
|
||||||
CIntegerParameter maxheight( camera.GetNodeMap(), "SensorHeight" );
|
CIntegerParameter maxheight( camera.GetNodeMap(), "SensorHeight" );
|
||||||
return maxheight.GetValue();
|
return maxheight.GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t sensorWidth(CInstantCamera &camera) {
|
uint32_t sensorWidth(CInstantCamera &camera) {
|
||||||
CIntegerParameter maxwidth( camera.GetNodeMap(), "SensorWidth" );
|
CIntegerParameter maxwidth( camera.GetNodeMap(), "SensorWidth" );
|
||||||
return maxwidth.IsValid() && maxwidth.IsReadable() ? maxwidth.GetValue() : 0;
|
return maxwidth.IsValid() && maxwidth.IsReadable() ? maxwidth.GetValue() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void exposureTime(double exposure_time);
|
|
||||||
|
void exposureTime(CInstantCamera &camera, double exposure_time) {
|
||||||
|
GenApi::INodeMap& nodemap = camera.GetNodeMap();
|
||||||
|
CFloatParameter(nodemap, "ExposureTime").SetValue(exposure_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void detectorGain(CInstantCamera &camera, double gain) {
|
||||||
|
GenApi::INodeMap& nodemap = camera.GetNodeMap();
|
||||||
|
CEnumParameter(nodemap, "GainAuto").SetValue("Off");
|
||||||
|
CEnumParameter(nodemap, "GainSelector").SetValue("All");
|
||||||
|
CFloatParameter(nodemap, "Gain").SetValue(gain);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char* argv[] ) {
|
int main( int argc, char* argv[] ) {
|
||||||
uint32_t frameCount = 100;
|
uint32_t frameCount = 100;
|
||||||
@ -59,9 +74,11 @@ int main( int argc, char* argv[] ) {
|
|||||||
int xOffset = 0;
|
int xOffset = 0;
|
||||||
int yOffset = 0;
|
int yOffset = 0;
|
||||||
int camIndex = 0;
|
int camIndex = 0;
|
||||||
|
double exposure_time = 10000;
|
||||||
|
double gains[2] = {5.0, 5.0};
|
||||||
string errorMessage = "";
|
string errorMessage = "";
|
||||||
String_t filename = "_TestVideo.mp4";
|
String_t filename = "_TestVideo.mp4";
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
std::string arg = argv[i];
|
std::string arg = argv[i];
|
||||||
if ((arg == "--help") || arg == "?"){
|
if ((arg == "--help") || arg == "?"){
|
||||||
@ -72,6 +89,9 @@ int main( int argc, char* argv[] ) {
|
|||||||
<< "\t --height|-h \t the image height in pixel, defaults to 2000\n"
|
<< "\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 --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 --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 --gain1|-g1 \t gain for camera 1 in db, defaults to 5.0\n"
|
||||||
|
<< "\t --gain2|-g2 \t gain for camera 2 in db, defaults to 5.0\n"
|
||||||
<< "\t --cameras|-c \t the desired number of cameras to grab at the same time, defaults to 1\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 --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"
|
<< "\t --quality|-q \t the qualtiy of the compression (0 < q <= 100), defaults to 50\n"
|
||||||
@ -100,6 +120,23 @@ int main( int argc, char* argv[] ) {
|
|||||||
if ((arg == "--yoffs" || arg == "-y") && i + 1 < argc) {
|
if ((arg == "--yoffs" || arg == "-y") && i + 1 < argc) {
|
||||||
yOffset = std::atoi(argv[++i]);
|
yOffset = std::atoi(argv[++i]);
|
||||||
}
|
}
|
||||||
|
if ((arg == "--exposure" || arg == "-e") && i + 1 < argc) {
|
||||||
|
exposure_time = std::atoi(argv[++i]);
|
||||||
|
}
|
||||||
|
if ((arg == "--gain1" || arg == "-g1") && i + 1 < argc) {
|
||||||
|
try {
|
||||||
|
gains[0] = std::stod(argv[++i]);
|
||||||
|
} catch (...) {
|
||||||
|
gains[0] = 5.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((arg == "--gain2" || arg == "-g2") && i + 1 < argc) {
|
||||||
|
try {
|
||||||
|
gains[1] = std::stod(argv[++i]);
|
||||||
|
} catch (...) {
|
||||||
|
gains[1] = 5.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
if ((arg == "--index" || arg == "-i") && i + 1 < argc) {
|
if ((arg == "--index" || arg == "-i") && i + 1 < argc) {
|
||||||
camIndex = std::atoi(argv[++i]);
|
camIndex = std::atoi(argv[++i]);
|
||||||
}
|
}
|
||||||
@ -157,7 +194,8 @@ int main( int argc, char* argv[] ) {
|
|||||||
CEnumParameter pixelFormat( nodemap, "PixelFormat" );
|
CEnumParameter pixelFormat( nodemap, "PixelFormat" );
|
||||||
CEnumParameter trigmode( nodemap, "TriggerMode");
|
CEnumParameter trigmode( nodemap, "TriggerMode");
|
||||||
CEnumParameter trigsource( nodemap, "TriggerSource");
|
CEnumParameter trigsource( nodemap, "TriggerSource");
|
||||||
|
exposureTime( cameras[i], exposure_time );
|
||||||
|
detectorGain( cameras[i], gains[i] );
|
||||||
trigmode.TrySetValue( "On" );
|
trigmode.TrySetValue( "On" );
|
||||||
trigsource.TrySetValue( "Software" );
|
trigsource.TrySetValue( "Software" );
|
||||||
width.TrySetValue( cWidth, IntegerValueCorrection_Nearest );
|
width.TrySetValue( cWidth, IntegerValueCorrection_Nearest );
|
||||||
@ -236,6 +274,7 @@ int main( int argc, char* argv[] ) {
|
|||||||
for ( int i =0; i < camCount; ++i ) {
|
for ( int i =0; i < camCount; ++i ) {
|
||||||
success = success & frames[i]->GrabSucceeded();
|
success = success & frames[i]->GrabSucceeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
if ( camCount > 1 ) {
|
if ( camCount > 1 ) {
|
||||||
leftImage.AttachGrabResultBuffer( frames[0] );
|
leftImage.AttachGrabResultBuffer( frames[0] );
|
||||||
@ -248,7 +287,7 @@ int main( int argc, char* argv[] ) {
|
|||||||
} else {
|
} else {
|
||||||
cout << "Error: " << std::hex << frames[0]->GetErrorCode() << std::dec << " " << frames[0]->GetErrorDescription() << endl;
|
cout << "Error: " << std::hex << frames[0]->GetErrorCode() << std::dec << " " << frames[0]->GetErrorDescription() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
counter += 1;
|
counter += 1;
|
||||||
done = high_resolution_clock::now();
|
done = high_resolution_clock::now();
|
||||||
total_duration = duration_cast<microseconds>(done - before);
|
total_duration = duration_cast<microseconds>(done - before);
|
||||||
|
Loading…
Reference in New Issue
Block a user