How to get uniquely identify frame in Network Optix?
AnsweredI am developing a plugin which primary responsibility is saving each frame from camera video and passing the path of saved image to an API. This API is capable of detecting objects in images. So, it sends back coordinates as response to the plugin. Finally plugin receives the response and creates meta packets. So far it's working as I expected.
Now the issue is when I enable plugin for second camera it throws error. The problem is I am storing file name as file_path = std::to_string(m_lastVideoFrameTimestampUs)+".jpg". So, using the above logic it overwrites file with different cameras. The reason behind using `m_lastVideoFrameTimestampUs` it uniquely identifies a frame and `m_lastVideoFrameTimestampUs` is a available throughout the code, so that I don't need to externally pass the variable.
To resolve this I want to uniquely Identify a frame from multiple sources (cameras). Keeping this in my mind I have tried the following solutions,
1. Assigning a global incrementor
Prob: I assigned file_path = std::to_string(m_lastVideoFrameTimestampUs)+ std::to_string(i)+".jpg"; where i is incremented for each frame. I tried this it's creating file name as I expected, but when I access second camera, it starts for the previous value of last camera instead of 0. since I presumed plugin will be spawned as a thread for each camera.
2. generating random UUID
Prob: Again I am facing a similar issue, I used below code to generate random uuid,
std::string uuidGenerator()
{
random_generator gen;
uuid id = gen();
std::string tmp = boost::uuids::to_string(id);
return tmp;
}
using this I am able to save the file, tmp variable is not accessible to `cookSomeObjects` function. For my logic, this is where I am calling API.
3. Video frame meta data
I thought of print meta data of video frame so that I can get some info. So i tried this
NX_PRINT << videoFrame->metadataList();
It always prints `1`.
I don't know how to proceed further, any hint would be appreciable.
-
Hello Evgeny,
Thanks for the response. How to access camera GUID? Do you mean deviceinfo->id()? If so I am able to access that inside `ConsumingDeviceAgent` But how to access at pushUncompressedVideoFrame and cookSomeObjects function?
-
Hello Evgeny,
Thanks once again. I followed as you suggested. It's working.
Please sign in to leave a comment.
Comments
4 comments