Creating a popup picture next to the camera view

Answered

Comments

22 comments

  • Avatar
    Evgeny Balashov

    Something similar can be achieved through implementing a plugin using metadata SDK.

    If the integration is done, then the plugin will be able to send data from access control to the camera and attach an image to it. The object preview tab will show this information and the image.

    That's the only 'native' way to bring images into the VMS. Though, this implementation requires using C++.

     

    An alternative would be to implement a virtual MJPEG camera, that streams required information as images. This camera could be saved on the layout in advance, or can pop-up on alarm layout using events.

     

    Does this help in any way? 

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hello Ali Ergin Hacimahmutoglu,

    When a person swipes the access card to the system, system shows the person's id specs and pictures next to the camera, and it also it puts a book mark.

    As Evgeny has mentioned, the native way is to create an analytics plugin, which would receive person's id specs from your application, transform them to the object metadata with preset coordinates and pass it to the Server. This metadata will be displayed over the frame in the GUI similar to shown in the screenshot attached.

    The bounding box can be made sero-sized. Box coordinates can be set to any place of the frame.
    On the right, you see the object preview tab, where a custom image can be shown if needed.

    0
    Comment actions Permalink
  • Avatar
    Jason Lee

    Evgeny Balashov is this a similar use case referring the alternative virtual MJPEG camera?
    https://youtu.be/TVRN29bhQKE?t=508

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Evgeny and Andrey descriptions for way to do, is very clear.  Only things to be done, is little coding. 

    Thanks for help. 

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Hi  Andrey; 

     I just want to ask question according to about your post  above. As you said, I want to add a picture to rectangle in bounding box , however I could not find type class of rectangle class in sample codes. If I can figure out the type class of the rectangle, I can easily cast the object to this rectangle type and put the image in. Could  you help me about this? Do you have sample codes? 

    Thanks.

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Hello;   

         I want to clarify one issue about my question that I have asked in my previous posts. The picture that will be shown next to the camera view, will come from a database. These are predefined images. They are not an instant taken image by the nx system. I guess the previous posts mostly explained about the images that, are displayed on the right. They are sent by the metadata object and instant taken live images.

    So is there a possibility to put a custom image in the rectangle of the bounding box?(I also asked in my previous post).

    Thanks,

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hi Ali,

    I just want to ask question according to about your post above. As you said, I want to add a picture to rectangle in bounding box , however I could not find type class of rectangle class in sample codes. If I can figure out the type class of the rectangle, I can easily cast the object to this rectangle type and put the image in. Could you help me about this? Do you have sample codes?

    Yes, we do.
    Have a look at stub_analytics_plugin in the "samples" folder of the Metadata SDK.
    In particular, the Ptr<IMetadataPacket> DeviceAgent::generateObjectMetadataPacket() method.

    Here is how the bounding box is set.

    objectMetadata->setBoundingBox(Rect(x, y, width, height));
    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    So is there a possibility to put a custom image in the rectangle of the bounding box?(I also asked in my previous post).

    Yes, there is.
    This image is set in the best shot metadata packet.

    Have a look at stub_analytics_plugin of the Metadata SDK.

    The samples/stub_analytics_plugin/src/nx/vms_server_plugins/analytics/stub/device_agent.cpp has a method std::vector<IMetadataPacket*> DeviceAgent::cookSomeObjects()
    See the code

    if (previewIsNeeded)
    {
    const auto position = object->position();
    const auto size = object->size();
    auto bestShotPacket = new ObjectTrackBestShotPacket(
    object->id(),
    metadataTimestampUs,
    Rect(position.x, position.y, size.width, size.height));

    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);
    }

    result.push_back(bestShotPacket);
    context.isPreviewGenerated = true;
    }

    Here is the actual code setting the custom preview image.

    bestShotPacket->setImage(
    m_deviceAgentSettings.previewImageFormat,
    m_deviceAgentSettings.previewImage);

     

     

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Thanks Andrey,  codes are clear, I am working on it. 

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Hi Andrey,

    I  stucked in the codes that you have sent, I have a trouble with the coding lines below. It seems that, random object generator is not working somehow.

     if (!context)
    context = m_objectGenerator.generate(); //context is defined, cannot get a new object.

    if (!context)
    continue; this line is running and quits the loop

    Although, in the first two lines context is defined, m_objectGenerator  cannot create an object. Can  you  help me, what are the possible causes for it.  I am using the recent library that is released for the NX meta and no errors while building and running the project. I realized the 'quit the loop' with the help of NX_PRINT

    Thanks.  

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hi Ali,

    First. Object generator works in the stub_analytics_plugin for demo purposes. Have you checked it?

    Second. If Object Generator does not  work in your case, it means you not  are using it properly and most probably outside the stub_analytics_plugin.
    To figure out what's wrong need greater context of the objective and of your code.
    What is your objective?  What are you using the object generator for?

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Yes, I am trying to use it in sample_analytics_plugin (This is my base project. New things I generate, I put it in.)   This project also integrated with Nx library.  And generally stub_analytics_plugin_functions are working in sample_analytics_plugin.

    I also know that, objects folder has the classes for random object generator and  I added the objects folder into main sample folder. It seems its working. 

     Can it be a  exception for object generator?  Is ıt only works in the stub_analytics_plugin? 

    "What is your objective? What are you using the object generator for?" I just want to run this code in sample_analytics_plugin. That is all I need, I am also using sample_analytics_plugin with special adding's.

    Thanks.

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Ali,

    I see.
    Could you please share the entire code of your project demonstrating this issue?

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Andrey, 

    Could you please give us. Link address information, how can I share the project. 

    Thanks. 

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Ali,

    Just place your project on Google Drive or similar and place here a link to the archive.

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Hi Andrey,

    This is the wetransfer link for entire project. 

    https://we.tl/t-wcvEfOrEv8

    Thanks,  

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Ali,

    Got your code. Please allow me some time to investigate.

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hello Ali,

    You don't configure m_objectGenerator in your code with the object types of which it should generate objects.

    In the stub_analytics_plugin there is the updateObjectGenerationParameters() method, which configures m_objectGenerator with the setting values received from the GUI. It's invoked in the settingsReceived()

    void DeviceAgent::updateObjectGenerationParameters()
    {
    setObjectCount(m_deviceAgentSettings.numberOfObjectsToGenerate);
    setIsObjectTypeGenerationNeeded<Car>(m_deviceAgentSettings.generateCars);
    setIsObjectTypeGenerationNeeded<Truck>(m_deviceAgentSettings.generateTrucks);
    setIsObjectTypeGenerationNeeded<Pedestrian>(m_deviceAgentSettings.generatePedestrians);
    setIsObjectTypeGenerationNeeded<HumanFace>(m_deviceAgentSettings.generateHumanFaces);
    setIsObjectTypeGenerationNeeded<Bicycle>(m_deviceAgentSettings.generateBicycles);
    setIsObjectTypeGenerationNeeded<Stone>(m_deviceAgentSettings.generateStones);
    }

    Here is the code of the updateObjectGenerationParameters()

    template<typename ObjectType>
    void setIsObjectTypeGenerationNeeded(bool isObjectTypeGenerationNeeded)
    {
    if (isObjectTypeGenerationNeeded)
    {
    m_objectGenerator.registerObjectFactory<ObjectType>(
    []() { return std::make_unique<ObjectType>(); });
    }
    else
    {
    m_objectGenerator.unregisterObjectFactory<ObjectType>();
    }
    }

    So, in your code you need to register object types to be generated by calling

    m_objectGenerator.registerObjectFactory<ObjectType>()
    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Hi Andrey,
    I understand. Thanks for help. While taking the functions, I want to get less codes. But functions are connected together and without taking the part of the code you, it won't work of course.

    Again thanks for help.

    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Hello Andrey,

          I need to revise my question about displaying the popup picture. Also you can check the beginning of the post. The popup picture, that I want to show is the next to the video screen. Please check the picture on the below, I want to show a popup picture(might come from a database) near the camera view.

          The preview image that, we have mentioned in the previous post above, is displayed on the right of the Nx Witness client screen in object preview screen(Also you can check this link below in that post)

    https://support.networkoptix.com/hc/en-us/community/posts/360051348154-Custom-image-in-objects-list 

          Nx Witness client grid pane is divided into the parts, if you drag a picture or a video into the pane, it will be displayed. (just like the picture above) My question is; I think, there should be a coding which can be implemented in sdk or a http request that can be triggered from Api , it will get  a specific picture from a  defined url or from a database and show it on the Nx-witness client grid pane. Can you help me about it. 

    Thanks. 

     

    0
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    Hi Ali,

    Let me first recap the questions you asked.

    So is there a possibility to put a custom image in the rectangle of the bounding box?(I also asked in my previous post).

    No, it's not possible. A "bounding" box is just a set of coordinates. See this post above

    As Evgeny mentioned

    An alternative would be to implement a virtual MJPEG camera, that streams required information as images. This camera could be saved on the layout in advance, or can pop-up on alarm layout using events.

    The link you've hared https://youtu.be/TVRN29bhQKE?t=508  demonstrates exactly this approach.

    The guys in the video use generic built in HTTP_URL_PLUGIN that presents any HTTP(s) URL as a camera.

    When adding a camera in the "Add devices" window you can type a URL presenting a single jpeg image or a series of jpeg images.

    There is another similar option.

    The Server is supplied with the IMAGE_LIBRARY plugin that can be activated. It facilitates jpeg images from the certain folder on the Server file system to be presented as a camera. See details here

    My question is; I think, there should be a coding which can be implemented in sdk or a http request that can be triggered from Api , it will get  a specific picture from a  defined url or from a database and show it on the Nx-witness client grid pane. Can you help me about it. 

    Taking said above into account, the solution could be the following.

    1. Predefine virtual cameras either by the HTTP_URL_PLUGIN or by the IMAGE_LIBRARY plugin.
    2. Predefine a layout where the camera and virtual cameras are arranged in a way you need.
    3. Predefine a rule opening this layout on the particular analytics event from you plugin.
    4. Your plugin gets the picture from the DB and saves it to the URL or to the folder on the Server file system.
    5. Your plugin triggers an analytics event.
    6. Server and GUI client process this analytics event, then in accordance to the rule GUI opens a predefined layout.

    Steps 1-3 can be done programmatically via Server API.

    For example,

    As you can see, there are three virtual cameras.

    1. Displays a picture (a smiling bowl) from the specific URL
    2. Displays a picture from the /tmp/pic1 directory on the Server.
    3. Displays a picture from the /tmp/pic2 directory on the Server.
    0
    Comment actions Permalink
  • Avatar
    Ali Ergin Hacimahmutoglu

    Hi Andrey, 

    Thanks for the detailed explanation. I think;  virtual MJPEG camera with streaming, is the most suitable solution. 

    Thanks for helping. 

      

    0
    Comment actions Permalink

Please sign in to leave a comment.