Control PTZ Presets with another Cameras Trigger

eangulus

Getting the hang of it
Joined
May 19, 2015
Messages
104
Reaction score
6
OK, so I sort of solved it using the same concept as Nayr.

I ended up writing a PHP script that will take the variables sent to it and trigger the PTZ, but has a built in delay + file locking to prevent the script being rerun until the delay ends. I then only linked to this script under a Night Profile, as it works 100% fine thru the day.

So now I am getting best of both worlds.

Thanks for the info Nayr, even thou I did it differently, I still achieved the same concepts you described. I still don't like the 30sec delay but it's the best I can do for now.

I may be able to improve my script thou. I could try adding in a list of the presets, and assign some way of prioritising some and maybe even set different delays depending on the distance of travel between each preset. This should let me get it even closer to an ideal setup.
 

eangulus

Getting the hang of it
Joined
May 19, 2015
Messages
104
Reaction score
6
OK coming across another issue.

I have a Total of 8 Cameras (will be 9 soon). 1x Huisun PTZ 2MP, 7(8) Hikvision 2032 3MP Series.

All are setup with most things switched off and run at 2048 Constant Bitrate, 15FPS with 15 IFrame.

BlueIris is running on Windows 7 x64, 10Gb RAM and an i7 2600 CPU. Gigabyte Network including Gigabyte PoE switch.

Now lately I have been getting sluggishness from the system. Slow to remote into (headless box), low frame rates from WebUI etc.

I have worked out that it was my clones slowing the system. Now admittedly I have around 12 Clones from 3 cameras (12 total clones), but I was under the impression that cloning would have very minimal impact on the PC as I am not recording or doing anything with the clones other than motion detection and the alert trigger. I even set them to no web stream etc as well. I wanted them to be hidden as i don't need them other than for the Motion and Trigger.

Is this suppose to happen or have I gotten something wrong? Also, would it be possible to instead of getting the camera feed from the camera, can I get it from BlueIris itself? If so what is the URL to use to collect one of BlueIris's camera feeds?

PS: The PHP Script I wrote to try and solve the Night motion issue works mostly, still not 100% but much better than without it. If anyone would like some to help maybe see if they can tweak the script to work better or just want to use my solution I have pasted the script below.

Code:
<?php
class pid {
    protected $filename;
    public $already_running = false;
    
    function __construct($directory) {
        $this->filename = $directory . '/' . basename($_SERVER['PHP_SELF']) . '.pid';
        
        if(is_writable($this->filename) || is_writable($directory)) {
            if(file_exists($this->filename)) {
                $pid = (int)trim(file_get_contents($this->filename));
                
                if(posix_kill($pid, 0)) {
                    $this->already_running = true;
                }
            }
        } else {
            die("Cannot write to pid file '$this->filename'. Program execution halted.\n");
        }
        
        if(!$this->already_running) {
            $pid = getmypid();
            file_put_contents($this->filename, $pid);
        }
    }
    
    public function __destruct() {
        if(!$this->already_running && file_exists($this->filename) && is_writeable($this->filename)) {
            unlink($this->filename);
        }
    }
}


function httpPost($url) {
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_HEADER, false);
    // curl_setopt($ch, CURLOPT_POST, count($postData));
    // curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);


    $output=curl_exec($ch);


    curl_close($ch);
    return $output;
}










$pid = new pid('/tmp');


if($pid->already_running) {
    // echo "Already running.\n";
    exit;
} else {
    httpPost("http://ecs.selfip.com:8000/admin?user=your-username&pw=your-password&camera=your-ptz-camera-name&preset=".htmlspecialchars($_GET["preset"]));
    sleep(20);
}
?>
 

lgRich

Young grasshopper
Joined
Mar 9, 2014
Messages
84
Reaction score
20
Location
Québec Canada

eangulus

Getting the hang of it
Joined
May 19, 2015
Messages
104
Reaction score
6
That doesn't seem to solve the problem. You can't have a seperate alert to a command, URL or script, per detection zone. The solution would be to have multiple alerts per camera that you can set depending on which zone was triggered. This would then cut down on the number of clones needed, maybe even eliminating the need for clones.
 

eangulus

Getting the hang of it
Joined
May 19, 2015
Messages
104
Reaction score
6
And if you read the this thread, you can see that we worked out how to trigger the ptz to preset from another camera. Problem is you can only set one alert rule each camera.
 

ronan

Young grasshopper
Joined
Jul 21, 2015
Messages
33
Reaction score
14
I know this part of the problem has already been solved, but can't you just (on the trigger tab) use re-trigger camera groups?

Add a unique group to your PTZ cam
On the camera which gets triggered, goto trigger tab, set re-trigger camera group
Goto PTZ trigger tab, set the PTZ to goto a preset when triggered.

Still might have to use a cloned/hidden camera. Could be more or less elegant than the previous suggestions depending on what you want to do.
 

eangulus

Getting the hang of it
Joined
May 19, 2015
Messages
104
Reaction score
6
Won't that limit it to one preset?

Who do I have to message to ask about possibly getting seperate alert rules to run with each zone setup as a possible feature request?

This is what will ultimately solve it. Then I could just setup each trigger zone on the real cameras (no clones unless you run out of zones) and then set the alerts for each zone accordingly.
 

ronan

Young grasshopper
Joined
Jul 21, 2015
Messages
33
Reaction score
14
Who do I have to message to ask about possibly getting seperate alert rules to run with each zone setup as a possible feature request?

This is what will ultimately solve it. Then I could just setup each trigger zone on the real cameras (no clones unless you run out of zones) and then set the alerts for each zone accordingly.
I'd say you'd have to email the developer. Have you done that yet? i'd like this type of functionality too.
 

SyconsciousAu

Getting comfortable
Joined
Sep 13, 2015
Messages
872
Reaction score
825
I have worked out that it was my clones slowing the system. Now admittedly I have around 12 Clones from 3 cameras (12 total clones), but I was under the impression that cloning would have very minimal impact on the PC as I am not recording or doing anything with the clones other than motion detection and the alert trigger. I even set them to no web stream etc as well. I wanted them to be hidden as i don't need them other than for the Motion and Trigger.
Are you using the main or the sub stream for the clones? I have a clones triggering PTZ presets using JsonBI, and prior to that callurl worked too, but I am using a low bitrate CIF substream. If you are using the main stream BI still has to process all that data to look through it.
 

eangulus

Getting the hang of it
Joined
May 19, 2015
Messages
104
Reaction score
6
I am using the main stream. I thought that being hd streams, if I were to use the sub stream, it may not detect the motion as accurately.
 

jazzy1

Getting the hang of it
Joined
Mar 23, 2015
Messages
300
Reaction score
38
This can be done in Blue Iris. On the camera that is going to send the PTZ from on record, go to Camera properties and Alerts. Under Ations check "Request from a web service" Configure "When triggered" like this.
127.0.0.1:8021/admin?camera=BK2&preset=5

Replace 8021 with your actual web server port.
Replace BK2 with the camera short name of the camera you want to do the PTZ
Replace 5 with the preset number you want to go to.
127.0.0.1 is a address that points to itself so no need to change it if the camera is local.

Edit: you may need to add "&user=[username]&pw=[password]" to the end of the command.
I'm not near my Blue Iris system right now so I am going by memory..
Replace [username] and [password] with actual username and password.

Hi guys, I'm trying to get this going using the above method and having NO LUCK...when clicking TEST it says "7878 bytes received"....any ideas?
 

Dasstrum

IPCT Contributor
Joined
Nov 4, 2016
Messages
578
Reaction score
736
Location
Florida
Hi guys, I'm trying to get this going using the above method and having NO LUCK...when clicking TEST it says "7878 bytes received"....any ideas?
Have you verified that the username and password you enter match?

if you open internet explorer and type in your camera's IP address does a login page for that camera open? IF yes, then does the username and password you enter allow you to log into the camera?
 

jazzy1

Getting the hang of it
Joined
Mar 23, 2015
Messages
300
Reaction score
38
Have you verified that the username and password you enter match?

if you open internet explorer and type in your camera's IP address does a login page for that camera open? IF yes, then does the username and password you enter allow you to log into the camera?
Hi! yes to both questions...also, the IP entered for the actual command is the internal LAN Blueiris server IP right?...I've got that entered

Here's what I've got entered:
10.0.1.xx:xxxx/ admin?camera=ptzee&preset=3&username=xxxxx&password=xxxxxxx

when I click test it says "received 7878 bytes"
 

Dasstrum

IPCT Contributor
Joined
Nov 4, 2016
Messages
578
Reaction score
736
Location
Florida
Hi! yes to both questions...also, the IP entered for the actual command is the internal LAN Blueiris server IP right?...I've got that entered

Here's what I've got entered:
10.0.1.xx:xxxx/ admin?camera=ptzee&preset=3&username=xxxxx&password=xxxxxxx

when I click test it says "received 7878 bytes"
Yes IP is the lan address for BI server

Username needs to be "user" and password needs to be "pw". Not all spelled out. Also it looks like in your above example you have a space between xxx/ and admin. This needs to be all together.
 

jazzy1

Getting the hang of it
Joined
Mar 23, 2015
Messages
300
Reaction score
38
OK, I feel like I'm close, but this is really weird...clicking TEST returns the "received 7878 bytes" message, and triggering the camera whose motion I want to trigger the PTZ either in BlueIris OR physically walking in front of it DOES NOTHING. But, if I copy the line of code and paste into a browser, then the PTZ moves to the desired preset, and the following in the browser appears:

signal=green
profile=-1
camera=PTZ
 

jaycanter

Getting the hang of it
Joined
Mar 1, 2015
Messages
124
Reaction score
33
@jazzy1 are you using the short name for the cam? I have 8 cameras in the front of my house that all trigger different presets but had to use the 2nd short name of the ptz cam. I have all cams with same login and password in BI so i don't have to have username and password in the command line.
 

jazzy1

Getting the hang of it
Joined
Mar 23, 2015
Messages
300
Reaction score
38
@jazzy1 are you using the short name for the cam? I have 8 cameras in the front of my house that all trigger different presets but had to use the 2nd short name of the ptz cam. I have all cams with same login and password in BI so i don't have to have username and password in the command line.
Yes I’m using the short name for the ptz I want to trigger.
 

jaycanter

Getting the hang of it
Joined
Mar 1, 2015
Messages
124
Reaction score
33
@jazzy1 here's what i am using under configure web alert xxx.xxx.xxx.x:xx/cam/ptz1/preset=4

i just copy and paste into it and change preset i have 2 Dahua PTZ's running off of this
 

jazzy1

Getting the hang of it
Joined
Mar 23, 2015
Messages
300
Reaction score
38
still not working for me....it almost feels like it's not logging into the server properly when executing this line ?!
this is so frustrating...is it a firewall thing?!...must be some tiny setting somewhere..

I know that syntax also seems to work jaycanter because I pasted it in a browser and get "OK" and then the PTZ camera DOES move....something is happening within Blueiris which is preventing it from working though
 
Last edited:
Top