IP Cam Talk

Welcome to the new IPCT! If you are having an issue logging in, please clear your cookies / cache.

Trigger blue iris with IVS?

hmjgriffon

Known around here
Joined
Mar 30, 2014
Messages
3,383
Reaction score
974
Location
North Florida
Can it be done? I've looked all over the web interface and it doesn't look like I can send a trigger to BI if I set up a trip wire on the camera.
 

cor35vet

IPCT Contributor
Joined
Jun 23, 2016
Messages
337
Reaction score
208
The cameras has an API, Blue Iris has an API. So it's definitely possible with some middleware.
I'll post something today to access the Dahua one with Python and pycurl.
Should be easy to adapt to do what you want.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,346
Reaction score
5,252
Location
Denver, CO
the problem is Ive found no documented API that works for IVS, none of the public API docs mention IVS at all and Ive tried reverse engineer and got nowhere.
 

cor35vet

IPCT Contributor
Joined
Jun 23, 2016
Messages
337
Reaction score
208
Because nobody writes documentation ;)
Available events:
Code:
VideoMotion
CrossLineDetection,CrossRegionDetection,LeftDetection,SceneChange,TakenAwayDetection,FaceDetection,RioterDetection,MoveDetection,WanderDetection,CrossFenceDetection,ParkingDetection,NumberStat,RetrogradeDetection,TrafficJunction
VideoBlind
AudioAnomaly,AudioMutation
VideoAbnormalDetection,SceneChange
LoginFailure
Source: Alarm tab of camera webui + F12/inspect -> network

Example script to watch cameras on event: https://i.botox.bz/watch.py
Just add the additional ones to the event line if you use those.
for example:
Code:
"events": "VideoMotion,VideoBlind,VideoAbnormalDetection,SceneChange,CrossLineDetection,CrossRegionDetection,LeftDetection,SceneChange,TakenAwayDetection,FaceDetection,RioterDetection,MoveDetection,WanderDetection,CrossFenceDetection,ParkingDetection,NumberStat,RetrogradeDetection,TrafficJunction"
You can adapt that script to then trigger the BlueIris record event for that camera.
I don't have BlueIris so ¯\_(ツ)_/¯ but I did read that it has a JSON API which can do just that.

Example output:
Code:
python watch.py
[0] OnConnect()
[0] ParseAlarm({'Code': 'CrossLineDetection', 'action': 'Start', 'index': '0'})
[0] Alarm triggered! -> ON
[0] StartPlayer()
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,346
Reaction score
5,252
Location
Denver, CO
must of been an older firmware I was working, cause I subscribed to events and got nothing IVS related out of it.. Motion/Audio/Alarm all worked but it announced nothing on IVS events.

it was one of the first IVS cameras and first IVS firmware, bet it was broken and they later fixed it.
 

Alimanya

n3wb
Joined
Nov 26, 2016
Messages
9
Reaction score
5
Can it be done? I've looked all over the web interface and it doesn't look like I can send a trigger to BI if I set up a trip wire on the camera.
I have Blue iris setup in a lab environment waiting on some starlights. In the mean time, I have been playing with a Hikvision DS-2CD2042WDI and have the Hik IVS line crossing / intrusion detection working with a blue iris. Really hoping it will also work with Dahua's.


upload_2017-2-27_21-46-33.png
upload_2017-2-27_21-49-8.png
 

Go3Team

Pulling my weight
Joined
Mar 13, 2017
Messages
147
Reaction score
109
Location
RVA
Because nobody writes documentation ;)
Available events:
Code:
VideoMotion
CrossLineDetection,CrossRegionDetection,LeftDetection,SceneChange,TakenAwayDetection,FaceDetection,RioterDetection,MoveDetection,WanderDetection,CrossFenceDetection,ParkingDetection,NumberStat,RetrogradeDetection,TrafficJunction
VideoBlind
AudioAnomaly,AudioMutation
VideoAbnormalDetection,SceneChange
LoginFailure
Source: Alarm tab of camera webui + F12/inspect -> network

Example script to watch cameras on event: https://i.botox.bz/watch.py
Just add the additional ones to the event line if you use those.
for example:
Code:
"events": "VideoMotion,VideoBlind,VideoAbnormalDetection,SceneChange,CrossLineDetection,CrossRegionDetection,LeftDetection,SceneChange,TakenAwayDetection,FaceDetection,RioterDetection,MoveDetection,WanderDetection,CrossFenceDetection,ParkingDetection,NumberStat,RetrogradeDetection,TrafficJunction"
You can adapt that script to then trigger the BlueIris record event for that camera.
I don't have BlueIris so ¯\_(ツ)_/¯ but I did read that it has a JSON API which can do just that.

Example output:
Code:
python watch.py
[0] OnConnect()
[0] ParseAlarm({'Code': 'CrossLineDetection', 'action': 'Start', 'index': '0'})
[0] Alarm triggered! -> ON
[0] StartPlayer()
Are you still using this code? I'm getting this error:

Code:
Traceback (most recent call last):
  File "watch.py", line 217, in <module>
    Master.Run()
  File "watch.py", line 187, in Run
    Camera = next(filter(lambda x: x.CurlObj == CurlObj, self.Cameras))
TypeError: list object is not an iterator
I get it when using:

Code:
"events": "VideoMotion,CrossLineDetection"
But not when using:

Code:
"events": "VideoMotion"
or

Code:
"events": "CrossLineDetection"
Any ideas?

Thanks.
 

cor35vet

IPCT Contributor
Joined
Jun 23, 2016
Messages
337
Reaction score
208
Are you still using this code? I'm getting this error:

Code:
Traceback (most recent call last):
  File "watch.py", line 217, in <module>
    Master.Run()
  File "watch.py", line 187, in Run
    Camera = next(filter(lambda x: x.CurlObj == CurlObj, self.Cameras))
TypeError: list object is not an iterator
I get it when using:

Code:
"events": "VideoMotion,CrossLineDetection"
But not when using:

Code:
"events": "VideoMotion"
or

Code:
"events": "CrossLineDetection"
Any ideas?

Thanks.
Are you using python2 maybe?
This script needs python3.

Can't explain the error otherwise, looks unrelated.
 

Go3Team

Pulling my weight
Joined
Mar 13, 2017
Messages
147
Reaction score
109
Location
RVA
Are you using python2 maybe?
This script needs python3.

Can't explain the error otherwise, looks unrelated.
This seems to have helped:

Code:
# python3 watch.py
I'm just getting a bunch of this now:
Code:
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
 

cor35vet

IPCT Contributor
Joined
Jun 23, 2016
Messages
337
Reaction score
208
This seems to have helped:

Code:
# python3 watch.py
I'm just getting a bunch of this now:
Code:
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
[1] OnDisconnect(Success)
[0] OnDisconnect(Success)
This means that the camera closed the connection.
Wrong username/password maybe? Try the same request in your browser.
Or maybe your camera isn't using DIGEST auth? CurlObj.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_DIGEST)
 

Go3Team

Pulling my weight
Joined
Mar 13, 2017
Messages
147
Reaction score
109
Location
RVA
This means that the camera closed the connection.
Wrong username/password maybe? Try the same request in your browser.
Or maybe your camera isn't using DIGEST auth? CurlObj.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_DIGEST)
It worked pretty good before if I just had VideoMotion in there (but failed if I had
"events": "VideoMotion,CrossLineDetection")

Code:
#python watch.py
[0] OnConnect()
[0] ParseAlarm({u'action': u'Start', u'index': u'0', u'Code': u'VideoMotion'})
Motion Detected
[0] ParseAlarm({u'action': u'Stop', u'index': u'0', u'Code': u'VideoMotion'})
Motion Stopped

Now, if I do this: (not using python3 watch.py)

Code:
        {
                "host": "10.0.0.61",
                "port": 80,
                "user": "toot",
                "pass": "gas",
                "events": "VideoMotion"
        },
        {
                "host": "10.0.0.61",
                "port": 80,
                "user": "toot",
                "pass": "gas",
                "events": "CrossLineDetection"
        }
It seems to work ok:

Code:
# python watch.py
[0] OnConnect()
[1] OnConnect()
[0] ParseAlarm({u'action': u'Start', u'index': u'0', u'Code': u'VideoMotion'})
Motion Detected
[1] ParseAlarm({u'action': u'Start', u'index': u'0', u'Code': u'CrossLineDetection'})
Motion Detected
[1] ParseAlarm({u'action': u'Stop', u'index': u'0', u'Code': u'CrossLineDetection'})
Motion Stopped
[0] ParseAlarm({u'action': u'Stop', u'index': u'0', u'Code': u'VideoMotion'})
Motion Stopped
I don't use BI, I have my own NVR. I'm using this to tell Openhab that there is movement on one of the cameras.

Code:
def OnAlarm(self, State):
                #print("[{0}] Alarm triggered! -> {1}".format(self.Index, "ON" if State else "OFF"))

                if State:
                        #self.StartPlayer()
                        print("Motion Detected")
                        urllib2.urlopen("http://localhost:8080/CMD?Middle1=ON").read()
                else:
                        #self.StopPlayer()
                        print("Motion Stopped")
                        urllib2.urlopen("http://localhost:8080/CMD?Middle1=OFF").read()
 

Go3Team

Pulling my weight
Joined
Mar 13, 2017
Messages
147
Reaction score
109
Location
RVA
Just now. It just keeps asking for the name and password so I tried http://name:password@10.0.0.61/cgi-bin/eventManager.cgi?action=attach&codes=[VideoMotion,CrossLineDetection] and that does the same thing.

Strange

Edit:

So I did VideoMotion and CrossLineDetection separately, and it did what it was supposed to. Use them together and it hiccups. When I use the python script, CrossLineDetection sees me when I walk into the area, so that does work:

Code:
[1] ParseAlarm({u'action': u'Start', u'index': u'0', u'Code': u'CrossLineDetection'})
[1] ParseAlarm({u'action': u'Stop', u'index': u'0', u'Code': u'CrossLineDetection'})
 
Last edited:

johnnyletrois

Young grasshopper
Joined
Feb 13, 2017
Messages
41
Reaction score
7
Anyone tried this with HomeAssistant?
I managed to get it working and talking to HomeAssistant via MQTT. IVS detection seems much more reliable than motion, but I still seem to get false positives. Maybe I don't have IVS set up correctly. Is there a guide for the 5231 anywhere?
 

johnnyletrois

Young grasshopper
Joined
Feb 13, 2017
Messages
41
Reaction score
7
It worked pretty good before if I just had VideoMotion in there (but failed if I had
"events": "VideoMotion,CrossLineDetection")

Code:
#python watch.py
[0] OnConnect()
[0] ParseAlarm({u'action': u'Start', u'index': u'0', u'Code': u'VideoMotion'})
Motion Detected
[0] ParseAlarm({u'action': u'Stop', u'index': u'0', u'Code': u'VideoMotion'})
Motion Stopped

Now, if I do this: (not using python3 watch.py)

Code:
        {
                "host": "10.0.0.61",
                "port": 80,
                "user": "toot",
                "pass": "gas",
                "events": "VideoMotion"
        },
        {
                "host": "10.0.0.61",
                "port": 80,
                "user": "toot",
                "pass": "gas",
                "events": "CrossLineDetection"
        }
It seems to work ok:

Code:
# python watch.py
[0] OnConnect()
[1] OnConnect()
[0] ParseAlarm({u'action': u'Start', u'index': u'0', u'Code': u'VideoMotion'})
Motion Detected
[1] ParseAlarm({u'action': u'Start', u'index': u'0', u'Code': u'CrossLineDetection'})
Motion Detected
[1] ParseAlarm({u'action': u'Stop', u'index': u'0', u'Code': u'CrossLineDetection'})
Motion Stopped
[0] ParseAlarm({u'action': u'Stop', u'index': u'0', u'Code': u'VideoMotion'})
Motion Stopped
I don't use BI, I have my own NVR. I'm using this to tell Openhab that there is movement on one of the cameras.

Code:
def OnAlarm(self, State):
                #print("[{0}] Alarm triggered! -> {1}".format(self.Index, "ON" if State else "OFF"))

                if State:
                        #self.StartPlayer()
                        print("Motion Detected")
                        urllib2.urlopen("http://localhost:8080/CMD?Middle1=ON").read()
                else:
                        #self.StopPlayer()
                        print("Motion Stopped")
                        urllib2.urlopen("http://localhost:8080/CMD?Middle1=OFF").read()

I'm terrible with python and programming in general. With multiple cameras, do you have any ideas how to distinguish which camera is sending the event? I'm sure it is something to do with index number of the cameras array (0, 1, 2, etc.). I'm just not sure how to do it.
 

cor35vet

IPCT Contributor
Joined
Jun 23, 2016
Messages
337
Reaction score
208
I'm terrible with python and programming in general. With multiple cameras, do you have any ideas how to distinguish which camera is sending the event? I'm sure it is something to do with index number of the cameras array (0, 1, 2, etc.). I'm just not sure how to do it.
self.Index is the index of the config dict (host, port, ...), starting from 0.
 

johnnyletrois

Young grasshopper
Joined
Feb 13, 2017
Messages
41
Reaction score
7
self.Index is the index of the config dict (host, port, ...), starting from 0.
Thanks. I got that but was having trouble figuring out how to insert it into my MQTT url. I figured it out just now and it works great!


sensorurl = ("home-assistant/cameras/{0}/IVS").format(self.Index);
client.publish(sensorurl, "ON");
 
Top