/* * @Author: xiewenji 527774126@qq.com * @Date: 2025-09-13 20:39:37 * @LastEditors: xiewenji 527774126@qq.com * @LastEditTime: 2025-09-24 14:17:12 * @FilePath: /BOE_FOG_Detect/AlgorithmModule/src/CameraResult.cpp * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ #include "CameraResult.h" CameraResult::CameraResult() { cameraBaseResult = std::make_shared(); detlog = std::make_shared(); time_start = 0; } CameraResult::~CameraResult() { } void CameraResult::AddLog(std::string str) { LogList.push_back(str); } int CameraResult::AddDetImage(std::shared_ptr p) { if (time_start == 0) { time_start = CheckUtil::getcurTime(); /* code */ } std::shared_ptr imgResult = std::make_shared(); imgResult->cameraBaseResult = cameraBaseResult; imgResult->productBaseResult = productBaseResult; if (p->Det_Mode == DET_MODE_ReJson) { bJson = true; } imgResult->AddDetImage(p); { std::lock_guard lock_cam(mtx_DetImageList); ImageALLDetResultList.push_back(imgResult); } { std::lock_guard lock_cam(mtx_Det); if (p->strChannel == "L255") { bHave_L255 = true; } if (p->strChannel == "Down-Particle") { bHave_DP = true; } if (p->strChannel == "Up-Particle") { bHave_Up = true; } } std::string strTimg = CheckUtil::getCurTimeHMS(); detlog->AddCheckstr(PrintLevel_0, "PushInImg", " product %s Cam %s add new image channel = %s sum img %ld %s", productBaseResult->strproductName.c_str(), cameraBaseResult->strCameraName.c_str(), imgResult->strChannel.c_str(), ImageALLDetResultList.size(), strTimg.c_str()); return 0; } bool CameraResult::bCheckCamplate() { std::lock_guard lock_cam(mtx_Det); if (checkStep == Check_Step_Complete) { return true; } return false; } Check_Step CameraResult::GetCheckStep() { std::lock_guard lock_cam(mtx_Det); return checkStep; } void CameraResult::SetCheckStep(Check_Step step) { std::lock_guard lock_cam(mtx_Det); checkStep = step; } bool CameraResult::getImgPushComplate() { std::lock_guard lock_cam(mtx_Det); return bIsImgComplete; } void CameraResult::setImgPushComplate() { std::lock_guard lock_cam(mtx_Det); bIsImgComplete = true; } bool CameraResult::IsHaveL255() { std::lock_guard lock_cam(mtx_Det); return bHave_L255; } bool CameraResult::Have_EdgeImg(std::string strConfig_Channel) { std::lock_guard lock_cam(mtx_DetImageList); for (auto ptr : ImageALLDetResultList) { if (ptr->IsChannel(strConfig_Channel)) { return true; } } return false; } void CameraResult::SetHaveL255(bool b) { std::lock_guard lock_cam(mtx_Det); bHave_L255 = b; } bool CameraResult::IsHaveDP() { std::lock_guard lock_cam(mtx_Det); return bHave_DP; } void CameraResult::SetHaveDP(bool b) { std::lock_guard lock_cam(mtx_Det); bHave_DP = b; } bool CameraResult::IsHaveUp() { std::lock_guard lock_cam(mtx_Det); return bHave_Up; } void CameraResult::SetHaveUp(bool b) { std::lock_guard lock_cam(mtx_Det); bHave_Up = b; } std::shared_ptr CameraResult::GetNoDetImg() { std::lock_guard lock_cam(mtx_DetImageList); // 优先 up 然后是 dp for (auto ptr : ImageALLDetResultList) { if (ptr->IsChannel("Up-Particle")) { if (ptr->IsNotDet()) { return ptr; } } } for (auto ptr : ImageALLDetResultList) { if (ptr->IsChannel("Down-Particle")) { if (ptr->IsNotDet()) { bool bok = true; if (ptr->config_update.wait_UP && cameraBaseResult->UpImg_Status != CameraBaseResult::ImageDet_Status_DetComplete) { bok = false; } if (bok) { return ptr; } } } } for (auto ptr : ImageALLDetResultList) { // 参数更新过了 if (ptr->config_update.bUpdate) { // 未检测的 if (ptr->IsNotDet()) { bool bok = true; // // 等待DP DP 没有 检测完成 if (ptr->config_update.wait_DP && cameraBaseResult->DPImg_Status != CameraBaseResult::ImageDet_Status_DetComplete) { bok = false; } if (ptr->config_update.wait_UP && cameraBaseResult->UpImg_Status != CameraBaseResult::ImageDet_Status_DetComplete) { bok = false; } if (bok) { return ptr; } } } } return nullptr; } std::shared_ptr CameraResult::GetL255DetImg() { std::lock_guard lock_cam(mtx_DetImageList); for (auto ptr : ImageALLDetResultList) { if (ptr->IsChannel("L255")) { return ptr; } } return nullptr; } std::shared_ptr CameraResult::GetEdgeChannel(std::string strConfig_Channel) { std::lock_guard lock_cam(mtx_DetImageList); for (auto ptr : ImageALLDetResultList) { if (ptr->IsChannel(strConfig_Channel)) { return ptr; } } return nullptr; }