优化网络拍照逻辑

onereq
Matthew 2 months ago
parent ebe52ca252
commit 6388002df2

@ -1451,9 +1451,7 @@ IDevice::timer_uid_t CPhoneDevice::RegisterTimer(unsigned int timerType, unsigne
bool CPhoneDevice::UnregisterTimer(IDevice::timer_uid_t uid) bool CPhoneDevice::UnregisterTimer(IDevice::timer_uid_t uid)
{ {
timer_t timer = (timer_t)uid; bool existed = false;
int res = timer_delete(timer);
m_devLocker.lock(); m_devLocker.lock();
std::map<IDevice::timer_uid_t, TIMER_CONTEXT*>::iterator it = mTimers.find(uid); std::map<IDevice::timer_uid_t, TIMER_CONTEXT*>::iterator it = mTimers.find(uid);
if (it != mTimers.end()) if (it != mTimers.end())
@ -1461,11 +1459,21 @@ bool CPhoneDevice::UnregisterTimer(IDevice::timer_uid_t uid)
delete it->second; delete it->second;
mTimers.erase(it); mTimers.erase(it);
m_devLocker.unlock(); m_devLocker.unlock();
return true; existed = true;
}
else
{
m_devLocker.unlock();
} }
m_devLocker.unlock(); if (existed)
return false; {
ALOGI("UnregisterTimer: %lld", uid);
timer_t timer = (timer_t)uid;
int res = timer_delete(timer);
}
return existed;
} }
uint64_t CPhoneDevice::RequestWakelock(uint64_t timeout) uint64_t CPhoneDevice::RequestWakelock(uint64_t timeout)
@ -1693,6 +1701,7 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
// strcpy(netPhotoInfo.interface, "eth0"); // strcpy(netPhotoInfo.interface, "eth0");
std::vector<uint8_t> img; std::vector<uint8_t> img;
cv::Mat rgb;
bool netCaptureResult = false; bool netCaptureResult = false;
for (int idx = 0; idx < 64; idx++) for (int idx = 0; idx < 64; idx++)
@ -1730,18 +1739,14 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
XYLOG(XYLOG_SEVERITY_INFO, "NetCapture Succeeded PHOTOID=%u Img Size=%u", localPhotoInfo.photoId, (uint32_t)img.size()); XYLOG(XYLOG_SEVERITY_INFO, "NetCapture Succeeded PHOTOID=%u Img Size=%u", localPhotoInfo.photoId, (uint32_t)img.size());
if(img.size() <= 1000) if(img.size() <= 1000)
{ {
std::string hexStr; std::string hexStr = ByteArrayToString(&img[0], img.size());
const size_t maxBytes = 128;
for (size_t i = 0; i < std::min(img.size(), maxBytes); ++i)
{
char buf[3];
snprintf(buf, sizeof(buf), "%02X", img[i]);
hexStr += buf;
hexStr += " ";
}
XYLOG(XYLOG_SEVERITY_DEBUG,"Img Size<1000, img=%s", hexStr.c_str()); XYLOG(XYLOG_SEVERITY_DEBUG,"Img Size<1000, img=%s", hexStr.c_str());
} }
break; rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR);
if (!rgb.empty())
{
break;
}
} }
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); std::this_thread::sleep_for(std::chrono::milliseconds(1000));
} }
@ -1749,11 +1754,6 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c
ethernetPowerCtrl.reset(); ethernetPowerCtrl.reset();
XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Power OFF"); XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Power OFF");
cv::Mat rgb;
if (netCaptureResult && !img.empty())
{
rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR);
}
if (!rgb.empty()) if (!rgb.empty())
{ {
time_t takingTime = ts; time_t takingTime = ts;
@ -3723,7 +3723,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat mat)
#endif #endif
textSize = ft2->getTextSize(it->text, fontSize, thickness, &baseline); textSize = ft2->getTextSize(it->text, fontSize, thickness, &baseline);
XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline); // XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline);
if (it->alignment == OSD_ALIGNMENT_TOP_LEFT) if (it->alignment == OSD_ALIGNMENT_TOP_LEFT)
{ {
@ -4023,7 +4023,7 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
#endif #endif
textSize = ft2->getTextSize(it->text, fontSize, thickness, &baseline); textSize = ft2->getTextSize(it->text, fontSize, thickness, &baseline);
XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline); // XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline);
if (it->alignment == OSD_ALIGNMENT_TOP_LEFT) if (it->alignment == OSD_ALIGNMENT_TOP_LEFT)
{ {

Loading…
Cancel
Save