Custom image in event MetadataPacket
AnsweredHello.
I'm currently working on integration with Metadata SDK and I want to bind a custom image to the analytics event so in that case the user will see notification with custom image provided by our image processing server.
I have posted similar question before and received an answer so I will clarify my issue below.
https://support.networkoptix.com/hc/en-us/community/posts/360051348154-Custom-image-in-objects-list
I tried to find the code sample written in response to my question and in the newer version of sdk (version 4.2) I've found similar functionality but that was not complete.
There is an setImage() function for ObjectTrackBestShotPacket class (which was not available in previous version of sdk) and currently I'm trying to use that function but I have no idea about setImage() function input parameters format which are imageDataFormat string and imageData vector.
I suppose that imageDataFormat can be jpeg, png or rgb, bgr so that needs some clarification. And the imageData vector is a convenient way to pass byte array.
So it will be great if you can help me to write correct imageDataFormat value.
Thanks.
-
Hello Ashot,
There is an setImage() function for ObjectTrackBestShotPacket class (which was not available in previous version of sdk) and currently I'm trying to use that function but I have no idea about setImage() function input parameters format which are imageDataFormat string and imageData vector.
There is a stub_analytics_plugin in the Metadata SDK. See the "samples" folder.
The DeviceAgent::cookSomeObjects() uses the setImage() method.
if (!m_deviceAgentSettings.previewImageUrl.empty())
{
bestShotPacket->setImageUrl(m_deviceAgentSettings.previewImageUrl);
}
else if (!m_deviceAgentSettings.previewImage.empty()
&& !m_deviceAgentSettings.previewImageFormat.empty())
{
bestShotPacket->setImage(
m_deviceAgentSettings.previewImageFormat,
m_deviceAgentSettings.previewImage);
}The setImage() method is defined in the src/nx/sdk/analytics/helpers/object_track_best_shot_packet.cpp
void ObjectTrackBestShotPacket::setImage(std::string imageDataFormat, std::vector<char> imageData)
{
setImageDataFormat(std::move(imageDataFormat));
setImageData(std::move(imageData));
}As you can see the first parameter imageDataFormat is just a string containing a format identifier.
The list of possible format identifier is introduced in the documentation of the IObjectTrackBestShotPacket1 interface class.
/**
* @return Format of the best shot image which is provided via imageData(). Can contain one of
* the following values: "image/jpeg", "image/png", "image/tiff" for JPEG, PNG and TIFF
* images correspondingly. If no image data is provided should return null.
*/
virtual const char* imageDataFormat() const = 0;That's bad of us. We'll correct the docs.
The imageData parameter is a vector of char, i.e. a vector of bytes that contains picture binary data, in other words a file of a picture in the format indicated in the imageDataFormat parameter.
0
Please sign in to leave a comment.
Comments
1 comment