add,计划采集6:

实现部分计划采集功能:定时任务可控制单反
This commit is contained in:
tangchao0503
2026-06-04 18:01:22 +08:00
parent 3607913f13
commit 41a1a938b9
11 changed files with 205 additions and 6 deletions

View File

@ -28,6 +28,8 @@ SingleLensReflexCameraWindow::SingleLensReflexCameraWindow(QWidget* parent)
connect(ui.stopTakePhoto_btn, &QPushButton::clicked, this, &SingleLensReflexCameraWindow::stopTakePhoto);
connect(this, &SingleLensReflexCameraWindow::stopTakePhotoSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::stopTakePhoto);
connect(this, &SingleLensReflexCameraWindow::OpenAndTakePhotoSLRCameraSignal, m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::OpenAndTakePhotoSLRCamera);
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamOpenedSignal, this, &SingleLensReflexCameraWindow::onCamOpened);
connect(m_SingleLensReflexCameraOperation, &SingleLensReflexCameraOperation::CamClosedSignal, this, &SingleLensReflexCameraWindow::onCamClosed);
@ -75,6 +77,20 @@ SingleLensReflexCameraWindow::~SingleLensReflexCameraWindow()
m_SingleLensReflexCameraOperation = nullptr;
}
void SingleLensReflexCameraWindow::onStartTimedDataCollection(int lineNum)
{
if (lineNum == 0)
{
OpenAndTakePhotoSLRCamera();
}
}
void SingleLensReflexCameraWindow::onStopTimedDataCollection()
{
stopTakePhoto();
closeSLRCamera();
}
void SingleLensReflexCameraWindow::onSelectDataFolder()
{
QString dir = QFileDialog::getExistingDirectory(this,
@ -118,6 +134,11 @@ void SingleLensReflexCameraWindow::takePhoto()
}
}
void SingleLensReflexCameraWindow::OpenAndTakePhotoSLRCamera()
{
emit OpenAndTakePhotoSLRCameraSignal();
}
void SingleLensReflexCameraWindow::stopTakePhoto()
{
if (m_SingleLensReflexCameraOperation->getRecordStatus())
@ -798,6 +819,64 @@ void SingleLensReflexCameraOperation::takePhoto()
}
}
void SingleLensReflexCameraOperation::OpenAndTakePhotoSLRCamera()
{
std::cout << "SingleLensReflexCameraOperation::OpenSLRCamera, 打开单反相机" << std::endl;
EdsError err = EDS_ERR_OK;
// 初始化SDK
err = initializeSDK();
if (err != EDS_ERR_OK)
{
emit ErrorSignal(QString::fromLocal8Bit("初始化SDK失败错误码: %1").arg(err));
return;
}
// 打开相机
err = openCamera();
if (err != EDS_ERR_OK)
{
terminateSDK();
emit ErrorSignal(QString::fromLocal8Bit("打开相机失败,错误码: %1").arg(err));
return;
}
// 设置保存到PC
err = setupSaveToHost();
if (err != EDS_ERR_OK)
{
closeCamera();
terminateSDK();
emit ErrorSignal(QString::fromLocal8Bit("设置保存位置失败,错误码: %1").arg(err));
return;
}
// 启动实时取景
err = startLiveView();
if (err != EDS_ERR_OK)
{
std::cout << "Warning: Failed to start live view, error: " << err << std::endl;
// 实时取景启动失败不是致命错误,继续执行
}
m_isRecord = true;
// 启动实时取景定时器约30fps
if (m_liveViewTimer && !m_liveViewTimer->isActive()) {
m_liveViewTimer->start(33); // 约30fps
}
m_captureTimer->start(m_captureIntervalMilliseconds);
//std::cout << "capture timer started (1 photo 3 second)" << std::endl;
emit CaptureStartedSignal();
emit CamOpenedSignal();
std::cout << "Camera opened, live view started." << std::endl;
}
void SingleLensReflexCameraOperation::setCaptureInterval(int captureIntervalSeconds)
{
m_captureIntervalMilliseconds = captureIntervalSeconds * 1000;