Connect from python to API and ONVIF

Hello, I’m starting an investigation to develop a integration with milestone. I have the SDK downloaded, the XProtect installed and also Onvif Bridge installed.

My current goals are:

1. connect to the API to get the camera list.

2. connect to the ONVIF bridge of the selected cameras with ffmpeg.

3. trigger alarms from API

For point 1 and 3, I got access to the api with the client samples (with XPMobileSDK.js) but I need to connect from server side with python code. I also checked the SOAP documentation but still is not clear for me what “endpoints” I have to use, and the credentials.

For point 2, I don’t know why, onvif bridge is not able to connect to my management server, in the logs appear the error:

`03-03-2020 13-28-29.791: Error - GlobalInit of c# library fails, hResult:0, return:-103-03-2020 13-29-10.112: Error - GlobalInit: error, System.Exception: ONVIF Bridge Not allowed with free surveillance

at VideoOS.OnvifGateway.OnvifMipLibrary.OnvifMipLibraryClass.GlobalInit(String aServerAddr, String aAdminusername, String aAdminPassword, String masterOnly, String& aErrorLog)

03-03-2020 13-29-10.112: Error - GlobalInit of c# library fails, hResult:0, return:-1`

- → I have added my license correctly and I insert correctly the credentials. I tried using Windows credentials and basic user (as admin) too.

Also, If i can connect somehow.. I don’t know how to connect to the stream, what is the format to obtain the rtsp streams of cameras? Any documentation?

Anything will be super helpfull,

THANKS in advance!

Hi.

Regarding the “For point 2”, this is not related to software development with

the MIP SDK, which is the focus of this forum, please ask again in the support

community, you should get better help from the partners using the support

community.

https://supportcommunity.milestonesys.com

The last question, these links might be helpful for you, please read them -

https://supportcommunity.milestonesys.com/s/article/ONVIF-Bridge-installation-and-setup-detailed-guide?language=en_US

https://doc.milestonesys.com/2020r1/en-US/standard_features/sf_onvifbridge/onvif_usingonvifclientstovi.htm?Highlight=onvif

https://doc.milestonesys.com/2020r1/en-US/standard_features/sf_onvifbridge/onvif_milestoneonvifbridgep.htm?Highlight=onvif

@Rie Kiuchi (Milestone Systems)​ Thank you very much it is super useful!

Any thoughts about 1) 3) related to the best way to obtain the camera list and trigger an alarm through api/soap in python?

Thanks again!

Hi Ricard,

As Rie mentioned point 2) is probably because you are using XPritect Essensials+.

About points 1) and 3) there is probably some misunderstanding here.

You can connect and get camera list on at least 3 different end-points:

  • Management server
  • Mobile server
  • ONVIF Bridge server

Every one of them uses different protocol.

So depending on what is comfortable to you, you should use the most appropriate one.

MS protocol is SOAP based and usually is running on ports 80 and 443.

MoS protocol is XML based and usually could be found on ports 8081 and 8082.

ONVIF protocol is also SOAP based and usually is waiting for request on port 580.

What you have mentioned (XPMobileSDK.js) is part of the MIP SDK Mobile. It is JS wrapper of the Mobile server protocol.

The point 3) however could most probably be achieved only on MS end point (depending on how you have configured your alarms..)

@Petar Vutov​ Cool, thank you! I knew the options but now is more clear to me. And it seems that based on what I need the best way to go is implement some layer over MS, right? could you point to me to the “endpoint/call/docs” that I have to use for this propose? (list cameras / trigger alarm) using MS.

For the 2) yes, I have a licence but installed the essensials+ in this computer, will change it, and hopefully will work fine.

Thanks again!

Hi Ricard,

The main page of Mobile Server protocol is placed here.

I suppose you are going to make protocol integration (not using some of the available SDKs), so you should go on “Getting started…” and “Mobile Server protocol”.

You should read at least “Mobile Server protocol introduction” (main page), and “Logon and Credentials”.

Use “Command Channel” as a reference to all the commands and possible parameters.

In your workflow you should call probably:

Connect

Login

GetAllViewsAndCameras

You can sniff communication on some of the JS samples (or XProtect Web Client) in order to understand/compare communication. JS samples parse response of GetAllViewsAndCameras in order to extract all the available cameras in the system from the auto-generated AllCameras view.

You will probably have difficulties with DH Key exchange, as you have to implement the whole workflow.

For testing purposes only you could try to enable plain text authentication vie change of Mobile server .config file.

Hi Petar thanks again. Yes, I will not use any available sdk because I have to connect from python code in linux) I will keep looking with this new information/links that you provide me, for the alarms part.

Thank you very much!

Hi @Ricard Pijoan Gassó​! I am currently trying to trigger events from my python script. As you faced similar problems i thought you could maybe give me a hint and help me out here. Thank you in advance :wink:

Hi @Jacob Nowak

You might find this article useful …Protocol integrations from Linux: Tips and Tricks

One of the samples creates an Alarm in XProtect, but it can be rewritten to create an Event.

“Samples shown are intentionally super-simple, to showcase the idea, and make it easier to “transcribe” them to other languages. For example, XML are in plain text” = you might be able to “transcribe” the samples to Python?!

HTH!

/Hans