I'm trying to debug a rare camera freeze issue. I'm thinking/hoping it's a software implementation issue on my end and not a camera hardware related issue.
If you Google (vs. forum search) "luxonis forums frozen camera" there are more results that have helped my infer what might be happening. I'm currently under the impression the queue gets full but I don't know this for sure yet.
When I have rgbQueue = device->getOutputQueue(STREAM_PREVIEW, 4, false);
as part of my pipeline initialization and then the below code block executing at an adaptive frame rate targeting 140fps (via OV9782):
- What happens if the queue gets "full"? Would my current implementation keep reading the same frame which gives the illusion of being frozen/stuck?
- I track
frameRepeatCount
against a threshold to determine this "frozen" state and it validates rarely for most users, where one user gets the issue consistently after at most 3-5 minutes of runtime. Any ideas what might be happening?
hasUpdatedFrame
seems to never get reset to true
due to the early returns (by design), but I'd like to know what can cause getting into this state to begin with?
- Is there a way (and is it a good idea) to clear the queue if I get into this "froze" state?
void UpdateFrame()
{
try
{
hasUpdatedFrame = false;
auto imgFrames = rgbQueue->tryGetAll<dai::ImgFrame>();
int count = imgFrames.size();
if (count <= 0)
return;
std::shared_ptr<dai::ImgFrame> imgFrame = imgFrames[count - 1];
if (!imgFrame)
return;
auto num = imgFrame->getSequenceNum();
bool isNewFrame = frameSequenceNum != num;
if (!isNewFrame)
{
frameRepeatCount++;
return;
}
frameSequenceNum = num;
hasUpdatedFrame = true;
cameraSettingsSummary.exposureTimeUs = imgFrame->getExposureTime().count();
cameraSettingsSummary.wbColorTemp = imgFrame->getColorTemperature();
cameraSettingsSummary.sensitivityIso = imgFrame->getSensitivity();
std::pair<cv::Mat, cv::Mat> result = toMatsFromPlanar(imgFrame->getData(), imgFrame->getWidth(), imgFrame->getHeight());
frameRGB = result.first;
frameBGR = result.second;
cv::cvtColor(frameRGB, frameRGBA, cv::COLOR_RGB2RGBA);
UpdateFpsActual();
}
catch (const std::exception &e)
{
std::cerr << "UpdateFrame error occurred: " << e.what() << std::endl;
}
}