Difference between revisions of "How to control your Foscam HD cameras - PTZ"

From ZoneMinder Wiki
Jump to navigationJump to search
Line 51: Line 51:
usr=xxxxx&pwd=xxxxxx
usr=xxxxx&pwd=xxxxxx
</nowiki>
</nowiki>
replace xxxx with your foscam login and password
replace xxxx with your foscam login and password. IMPORTANT: Remember its "usr" not "user" and "pwd" not "password"
* In Control Address type in  
* In Control Address type in  
  <nowiki>
  <nowiki>

Revision as of 14:03, 24 March 2015

<Home

Why I don't recommend using PTZ in ZM

You probably use zones to detect motion. If you move the camera around, you will mess up zones. Plus ZM's PTZ interface *sucks* :-) It's much better you directly use PTZ from your mobile app using one of the multitude of ipcamera apps available.


Making PTZ work for Foscam HD cameras (9831W, but should work on all others)

Zone minder already comes with a control script called FI9821W_Y2k.pm by Christophe Dapremont that does all the hard work. I only had to trivially modify it. the key change I made was that the script hardcodes an authentication login/password in the script. I removed it, and made it so that you can use the "Control Device" field of ZM to specify the password

I also noticed he did not add cruise mode - I might do that myself when I have the inclination (which I currently don't as I never use PTZ within ZM).

The updated PTZ script

You can find it here: https://github.com/arjunroychowdhury/zmhacks/blob/master/FI9831W_arc.pm (changes marked by #ARC)

How to set up ZM to recognize the script

  • Copy to /usr/share/perl5/ZoneMinder/Control
  • Make sure OPT_CONTROL is checked in Options->System of ZM
  • You also need to make sure you create a new control in ZM. To do this
    • Click on any monitor "source" column. That will bring up your configuration screen for that monitor
    • Click on "Edit" next to Control Type. This brings up a big list of existing controls (you won't see your new script here)
    • Click on "Add New Control"
      • Main Tab
        • Name: Foscam 9831W
        • Type: FFmpeg
        • Protocol:FI9831W_arc (IMPORTANT: needs to be exactly the same as the .pm file you just copied, except the .pm extension)
        • Check "Can Reset" leave the rest unchecked
      • Move Tab
        • Check CAN MOVE, CAN MOVE DIAGONALLY, CAN MOVE CONTINUOUS
      • Pan Tab
        • Check CAN PAN, min pan range =0, max pan range = 360, min pan step = 0, max pan step = 360
        • Check HAS PAN SPEED, min pan speed =0, max pan speed = 4
      • Tilt Tab
        • Check CAN TILT, and min tilt range=0, max tilt range=90; min tilt step=0, min tilt step=90
        • Check HAS TILT SPEED, min speed = 0, max speed = 4
      • Zoom, Focus, White, Iris Tabs -- leave unchecked (though I think it has WB)
      • Preset Tab
        • Check HAS PRESETS, NUM PRESETS=16, Check HAS HOME PRESET and CAN SET PRESETS


How to associate a camera to your new control

  • Click on the "source" column of your monitor
  • Click on Control Tab
  • Check "Controllable"
  • Control Type: Your new Control (FI9831W_arc) should now be in this list. If not, reboot ZM once, or restart it and it should show up. If not, you messed up something. Review previous section
  • In Control Device type in
usr=xxxxx&pwd=xxxxxx

replace xxxx with your foscam login and password. IMPORTANT: Remember its "usr" not "user" and "pwd" not "password"

  • In Control Address type in
 ip:port
 

of your camera

I also put in a value of 1 in auto stop timeout (I don't think it matters)

That's all, click and save

How to test

  • First off, monitor your logs while testing - it can tell you a lot if things don't work (I just do tail -f /var/log/syslog)
  • Click on the Name column of your monitor to which you just added PTZ control
  • Click on the "Control" link at the top of the new window showing your live stream
  • Control away (don't get impatient, ZM sometimes takes some time to process your control commands)

More fine tuning

Foscam has released its CGI User Manual - all PTZ controls are listed there. It's pretty easy to modify your script to make it more accurate and feature rich (example Cruise control) You can read the CGI document here. I'd strongly recommend you read it if you want to tinker.