Foscam Python2 Library for H.264 IP Cameras (FI9821W/P/HD816W/P)
- Support more camera models.
$ pip install pyfoscamHere is a simple example to move camera lens up and stop after 1s.
fromfoscamimportFoscamCamerafromtimeimportsleepmycam=FoscamCamera('192.168.0.110', 88, 'admin', 'pwd')
mycam.ptz_move_up()
sleep(1)
mycam.ptz_stop_run()This example uses the asynchronous feature provided by FoscamCamera.
Normally, a command is sent synchronously, waiting for results and blocking the main thread.
By initializing FoscamCamera with daemon=True (defaults to False), commands are sent asynchronously.
mycam=FoscamCamera('192.168.0.110', 88, 'admin', 'pwd', daemon=True)
mycam.get_ip_info()
mycam.get_port_info()
mycam.refresh_wifi_list()This example illustrates the use of a callback function when the command completes.
fromfoscamimportFoscamCamera, FOSCAM_SUCCESSdefprint_ipinfo(returncode, params):
ifreturncode!=FOSCAM_SUCCESS:
print'Failed to get IPInfo!'returnprint'IP: %s, Mask: %s'% (params['ip'], params['mask'])
mycam=FoscamCamera('192.168.0.110', 88, 'admin', 'pwd', daemon=False)
mycam.get_ip_info(print_ipinfo)