add getExposureTimeLimits
This commit is contained in:
109
uvoscam.cpp
109
uvoscam.cpp
@ -138,7 +138,7 @@ void Camera::aCallback(void* instance, int type, ArvBuffer *buffer)
|
||||
Camera* instance_ = reinterpret_cast<Camera*>(instance);
|
||||
if(type == ARV_STREAM_CALLBACK_TYPE_BUFFER_DONE)
|
||||
{
|
||||
if(instance_->run)
|
||||
if(instance_->run && instance_->aqmode != MODE_DISCARD)
|
||||
{
|
||||
gint inBuffers;
|
||||
gint outBuffers;
|
||||
@ -147,8 +147,6 @@ void Camera::aCallback(void* instance, int type, ArvBuffer *buffer)
|
||||
std::unique_lock<std::mutex> decodeBufferMutexLock(instance_->decodeBufferMutex);
|
||||
instance_->decodeBuffer = arv_stream_pop_buffer(instance_->aStream_);
|
||||
instance_->bufferCondition.notify_all();
|
||||
if(instance_->aqmode == MODE_SINGLE)
|
||||
instance_->run = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -194,13 +192,25 @@ bool Camera::chooseFormat()
|
||||
|
||||
bool Camera::setupCamera()
|
||||
{
|
||||
GError* error = nullptr;
|
||||
bool doubleRate = arv_camera_is_feature_available(aCamera_, "DoubleRate_Enable", &error);
|
||||
if(!error && doubleRate)
|
||||
{
|
||||
Log(Log::INFO)<<"Disable broken PhotonFocus DoubleRate implementation";
|
||||
arv_device_set_boolean_feature_value(arv_camera_get_device(aCamera_), "DoubleRate_Enable", false, &error);
|
||||
if(error)
|
||||
{
|
||||
Log(Log::ERROR)<<"Failed to disable DoubleRate\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!chooseFormat())
|
||||
{
|
||||
Log(Log::ERROR)<<"Camera provides no supported pixel format";
|
||||
return false;
|
||||
}
|
||||
|
||||
GError* error = nullptr;
|
||||
gint ymin, ymax;
|
||||
arv_camera_get_height_bounds(aCamera_, &ymin, &ymax, &error);
|
||||
if(error)
|
||||
@ -253,18 +263,6 @@ bool Camera::setupCamera()
|
||||
}
|
||||
Log(Log::DEBUG)<<"Binning: "<<(binning ? "yes" : "no");
|
||||
|
||||
bool doubleRate = arv_camera_is_feature_available(aCamera_, "DoubleRate_Enable", &error);
|
||||
if(!error && doubleRate)
|
||||
{
|
||||
Log(Log::INFO)<<"Disable broken PhotonFocus DoubleRate implementation";
|
||||
arv_device_set_boolean_feature_value(arv_camera_get_device(aCamera_), "DoubleRate_Enable", false, &error);
|
||||
if(error)
|
||||
{
|
||||
Log(Log::ERROR)<<"Failed to disable DoubleRate\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
decoderThread = new std::thread([this](){decoderThreadFunc();});
|
||||
|
||||
Log(Log::DEBUG)<<"Using "<<arv_camera_get_pixel_format_as_string(aCamera_, nullptr)<<" as pixel format";
|
||||
@ -282,12 +280,15 @@ bool Camera::setupCamera()
|
||||
imageBuffers[i] = arv_buffer_new(frameSize, nullptr);
|
||||
arv_stream_push_buffer(aStream_, imageBuffers[i]);
|
||||
}
|
||||
setExposureAuto(false);
|
||||
|
||||
arv_camera_stop_acquisition(aCamera_, nullptr);
|
||||
|
||||
setExposureAuto(true);
|
||||
setTriggerMode(TRIGGER_FREE);
|
||||
setAcquisitionMode(ARV_ACQUISITION_MODE_CONTINUOUS);
|
||||
setFrameRate(10);
|
||||
setExposureTime(100000);
|
||||
arv_camera_stop_acquisition(aCamera_, nullptr);
|
||||
setGain(1);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -395,6 +396,9 @@ bool Camera::setExposureTime(uint64_t us)
|
||||
{
|
||||
GError* error = nullptr;
|
||||
arv_camera_set_exposure_time(aCamera_, static_cast<double>(us), &error);
|
||||
if(error)
|
||||
Log(Log::WARN)<<error->message;
|
||||
|
||||
return !error;
|
||||
}
|
||||
|
||||
@ -402,6 +406,8 @@ uint64_t Camera::getExposureTime()
|
||||
{
|
||||
GError* error = nullptr;
|
||||
double ret = arv_camera_get_exposure_time(aCamera_, &error);
|
||||
if(error)
|
||||
Log(Log::WARN)<<error->message;
|
||||
return !error ? static_cast<uint64_t>(ret) : 0;
|
||||
}
|
||||
|
||||
@ -409,6 +415,8 @@ double Camera::getFrameRate()
|
||||
{
|
||||
GError* error = nullptr;
|
||||
double ret = arv_camera_get_frame_rate(aCamera_, &error);
|
||||
if(error)
|
||||
Log(Log::WARN)<<error->message;
|
||||
return !error ? ret : -1;
|
||||
}
|
||||
|
||||
@ -416,6 +424,8 @@ bool Camera::setFrameRate(double rate)
|
||||
{
|
||||
GError* error = nullptr;
|
||||
arv_camera_set_frame_rate(aCamera_, rate, &error);
|
||||
if(error)
|
||||
Log(Log::WARN)<<error->message;
|
||||
return !error;
|
||||
}
|
||||
|
||||
@ -424,13 +434,61 @@ int64_t Camera::getPixelFormat()
|
||||
return static_cast<ArvPixelFormat>(format);
|
||||
}
|
||||
|
||||
double Camera::getGain()
|
||||
{
|
||||
GError* error = nullptr;
|
||||
double gain = arv_camera_get_gain(aCamera_, &error);
|
||||
if(error)
|
||||
{
|
||||
Log(Log::WARN)<<error->message;
|
||||
return -1;
|
||||
}
|
||||
return gain;
|
||||
}
|
||||
|
||||
bool Camera::setGain(double gain)
|
||||
{
|
||||
GError* error = nullptr;
|
||||
arv_camera_set_gain(aCamera_, gain, &error);
|
||||
if(error)
|
||||
Log(Log::WARN)<<error->message;
|
||||
return !error;
|
||||
}
|
||||
|
||||
bool Camera::getExposureTimeLimits(uint64_t& min, uint64_t& max)
|
||||
{
|
||||
double minD = 0;
|
||||
double maxD = 0;
|
||||
GError* error;
|
||||
arv_camera_get_exposure_time_bounds(aCamera_, &minD, &maxD, &error);
|
||||
if(error)
|
||||
Log(Log::WARN)<<error->message;
|
||||
min = static_cast<uint64_t>(minD);
|
||||
max = static_cast<uint64_t>(maxD);
|
||||
return !error;
|
||||
}
|
||||
|
||||
bool Camera::hasExposureAuto()
|
||||
{
|
||||
GError* error = nullptr;
|
||||
bool ret = arv_camera_is_exposure_auto_available(aCamera_, &error);
|
||||
if(error)
|
||||
{
|
||||
Log(Log::WARN)<<error->message;
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Camera::setExposureAuto(bool enable)
|
||||
{
|
||||
if(!arv_camera_is_exposure_auto_available(aCamera_, nullptr))
|
||||
if(!hasExposureAuto())
|
||||
return false;
|
||||
|
||||
GError* error = nullptr;
|
||||
arv_camera_set_exposure_time(aCamera_, enable ? ARV_AUTO_CONTINUOUS : ARV_AUTO_OFF, &error);
|
||||
if(error)
|
||||
Log(Log::WARN)<<error->message;
|
||||
return !error;
|
||||
}
|
||||
|
||||
@ -439,7 +497,14 @@ bool Camera::startAcquisition()
|
||||
GError* error = nullptr;
|
||||
arv_camera_start_acquisition(aCamera_, &error);
|
||||
if(!error)
|
||||
{
|
||||
aqRunning = true;
|
||||
run = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(Log::WARN)<<error->message;
|
||||
}
|
||||
return !error;
|
||||
}
|
||||
|
||||
@ -448,7 +513,12 @@ bool Camera::stopAcquisition()
|
||||
GError* error = nullptr;
|
||||
arv_camera_stop_acquisition(aCamera_, &error);
|
||||
if(!error)
|
||||
{
|
||||
aqRunning = false;
|
||||
run = false;
|
||||
}
|
||||
else
|
||||
Log(Log::WARN)<<error->message;
|
||||
return !error;
|
||||
}
|
||||
|
||||
@ -501,6 +571,7 @@ Camera::Description Camera::getDescription()
|
||||
description->model = arv_camera_get_model_name(aCamera_, &error);
|
||||
if(error)
|
||||
{
|
||||
Log(Log::WARN)<<error->message;
|
||||
delete description;
|
||||
description = nullptr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user