|
@@ -51,7 +51,7 @@ getp:
|
|
|
long elapsed = (now.tv_sec - ctx->expTime0.tv_sec)*1000 + (now.tv_nsec-ctx->expTime0.tv_nsec)/(1000*1000);
|
|
long elapsed = (now.tv_sec - ctx->expTime0.tv_sec)*1000 + (now.tv_nsec-ctx->expTime0.tv_nsec)/(1000*1000);
|
|
|
sw_log_debug("[%s] +++GetOneFrame+++, 等待曝光完成, ExposureTime = %.2fus, ElapsedTime = %ldms", MODULE_NAME, curExpTime, elapsed);
|
|
sw_log_debug("[%s] +++GetOneFrame+++, 等待曝光完成, ExposureTime = %.2fus, ElapsedTime = %ldms", MODULE_NAME, curExpTime, elapsed);
|
|
|
|
|
|
|
|
- if((curExpTime-ctx->lastExpTime) > 100 && elapsed < 3*60*1000)
|
|
|
|
|
|
|
+ if((curExpTime != ctx->lastExpTime) && elapsed < 3*60*1000)
|
|
|
{
|
|
{
|
|
|
MV_CC_FreeImageBuffer(ctx->hCam, &frame);
|
|
MV_CC_FreeImageBuffer(ctx->hCam, &frame);
|
|
|
ctx->lastExpTime = curExpTime;
|
|
ctx->lastExpTime = curExpTime;
|
|
@@ -87,7 +87,7 @@ int TakePhoto(EImgType imgType, const char *saveImgFilename, int timeout, SImgMa
|
|
|
{
|
|
{
|
|
|
int fd; char runDir[MAX_PATH_CHARS] = { 0 }, lockFile[MAX_PATH_CHARS+32] = { 0 };
|
|
int fd; char runDir[MAX_PATH_CHARS] = { 0 }, lockFile[MAX_PATH_CHARS+32] = { 0 };
|
|
|
int ret; SImgMark imgMark = { 0 }; HANDLE hCam = NULL; PthotoProcCtx ctx = { 0 };
|
|
int ret; SImgMark imgMark = { 0 }; HANDLE hCam = NULL; PthotoProcCtx ctx = { 0 };
|
|
|
- MV_CC_DEVICE_INFO_LIST devList = { 0 }; MV_CC_DEVICE_INFO *pDevInfo = NULL;
|
|
|
|
|
|
|
+ MV_CC_DEVICE_INFO_LIST devList = { 0 }; MV_CC_DEVICE_INFO *pDevInfo = NULL; MVCC_ENUMVALUE exposureMode = { 0 };
|
|
|
|
|
|
|
|
// 1, 占用锁定, 避免同时间拍照
|
|
// 1, 占用锁定, 避免同时间拍照
|
|
|
xGetSelfRunningInfo(runDir, NULL);
|
|
xGetSelfRunningInfo(runDir, NULL);
|
|
@@ -151,23 +151,15 @@ int TakePhoto(EImgType imgType, const char *saveImgFilename, int timeout, SImgMa
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 4, 开始拍照, 等待完成后输出
|
|
// 4, 开始拍照, 等待完成后输出
|
|
|
- MVCC_ENUMVALUE ExposureMode = { 0 };
|
|
|
|
|
- ret = MV_CC_GetExposureAutoMode(hCam, &ExposureMode);
|
|
|
|
|
|
|
+ ret = MV_CC_GetExposureAutoMode(hCam, &exposureMode);
|
|
|
if(MV_OK != ret)
|
|
if(MV_OK != ret)
|
|
|
{
|
|
{
|
|
|
sw_log_error("[%s] 获取-曝光模式失败, errCode=0x%x!!", MODULE_NAME, ret);
|
|
sw_log_error("[%s] 获取-曝光模式失败, errCode=0x%x!!", MODULE_NAME, ret);
|
|
|
goto end_p;
|
|
goto end_p;
|
|
|
}
|
|
}
|
|
|
- if(ExposureMode.nCurValue != MV_EXPOSURE_AUTO_MODE_OFF) { ctx.isExposureAuto = true; clock_gettime(CLOCK_MONOTONIC, &ctx.expTime0); }
|
|
|
|
|
|
|
+ if(exposureMode.nCurValue != MV_EXPOSURE_AUTO_MODE_OFF) { ctx.isExposureAuto = true; clock_gettime(CLOCK_MONOTONIC, &ctx.expTime0); }
|
|
|
else ctx.isExposureAuto = false;
|
|
else ctx.isExposureAuto = false;
|
|
|
|
|
|
|
|
- if(ctx.isExposureAuto && sw_file_exists("exposure_time.txt"))
|
|
|
|
|
- {
|
|
|
|
|
- char buf[MAX_LINE_CHARS] = { 0 };
|
|
|
|
|
- int ret = sw_file_load("exposure_time.txt", "r", buf, sizeof(buf));
|
|
|
|
|
- if(ret > 0) MV_CC_SetExposureTime(hCam, (float)atof(buf));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
ret = MV_CC_StartGrabbing(hCam);
|
|
ret = MV_CC_StartGrabbing(hCam);
|
|
|
if(MV_OK != ret)
|
|
if(MV_OK != ret)
|
|
|
{
|
|
{
|
|
@@ -211,9 +203,9 @@ int TakePhoto(EImgType imgType, const char *saveImgFilename, int timeout, SImgMa
|
|
|
// 5, 成功拍照, 输出相机的信息
|
|
// 5, 成功拍照, 输出相机的信息
|
|
|
if(MV_OK == ret)
|
|
if(MV_OK == ret)
|
|
|
{
|
|
{
|
|
|
- char buf[MAX_LINE_CHARS] = { 0 }; sprintf(buf, "%.2f", ctx.lastExpTime);
|
|
|
|
|
- sw_file_update("exposure_time.txt", "w", buf, strlen(buf));
|
|
|
|
|
- imgMark.imgExposureTime = ctx.lastExpTime;
|
|
|
|
|
|
|
+ MVCC_FLOATVALUE fv = { 0 };
|
|
|
|
|
+ MV_CC_GetFloatValue(hCam, "ExposureTime", &fv);
|
|
|
|
|
+ imgMark.imgExposureTime = fv.fCurValue;
|
|
|
if(pImgMark) memcpy(pImgMark, &imgMark, sizeof(SImgMark));
|
|
if(pImgMark) memcpy(pImgMark, &imgMark, sizeof(SImgMark));
|
|
|
}
|
|
}
|
|
|
|
|
|