• 大小: 16KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: 其他
  • 标签:

资源简介

老外编写的PTZ控制代码,已调试完毕,无BUG,直接运行。老外编写的PTZ控制代码,已调试完毕,无BUG,直接运行。

资源截图

代码片段和文件信息

# -*- coding: utf-8 -*-
“““
Created on Mon Nov 17 10:24:49 2014

@author: chuong nguyen chuong.nguyen@anu.edu.au
“““

import sys
import cv2
import urllib
import numpy as np
import time
import re


class Camera(object):
    “““
    Control ACTi Camera
    Ref: http://www2.acti.com/getfile/Knowledgebase_UploadFile/ACTi_Camera_URL_Commands_20120327_002.pdf
    “““
    def __init__(self IP User Password ImageSize=None):
        self.IP = IP
        self.HTTPLogin = “http://{}/cgi-bin/encoder?“\
            “USER={}&PWD={}“.format(IP User Password)
        self.IMAGE_SIZES = [[1920 1080] [1280 720] [640 480]]
        if ImageSize:
            assert(ImageSize in self.IMAGE_SIZES)
            self.ImageSize = ImageSize
        self.Image = None
        self.PhotoIndex = 0

        self.Commands = {}
        self.Commands[“zoom_range“] = “&ZOOM_CAP_GET“
        self.Commands[“zoom_curpos“] = “&ZOOM_POSITION“
        self.Commands[“zoom_mode“] = “&ZOOM={}“
        self.Commands[“zoom_set“] = “&ZOOM={}{}“
        self.Commands[“zoom_step“] = “&STEPPED_ZOOM={}{}“

        self.Commands[“focus_range“] = “&FOCUS_CAP_GET“
        self.Commands[“focus_curpos“] = “&FOCUS_POSITION“
        self.Commands[“focus_mode“] = “&FOCUS={}“
        self.Commands[“focus_set“] = “&FOCUS={}{}“
        self.Commands[“focus_step“] = “&STEPPED_FOCUS={}{}“

        self.Commands[“snap_photo“] = “&SNAPSHOT=N{}x{}100&DUMMY={}“

        # Valid values for ACTi camera
        self.ZOOM_MODES = [“STOPS“]
        self.ZOOM_STATES = [“DIRECT“ “TELE“]
        self.ZOOM_STEP_DIRECTIONS = [“TELE“ “WIDE“]
        self.ZOOM_STEP_RANGE = [1 255]
        self.ZOOM_DIRECT_RANGE = self.getZoomRange()

        self.FOCUS_MODES = [“STOP“ “FAR“ “NEAR“ “AUTO“ “MANUAL“ “ZOOM_AF“
                            “REFOCUS“]
        self.FOCUS_STATES = [“DIRECT“]
        self.FOCUS_STEP_DIRECTIONS = [“NEAR“ “FAR“]
        self.FOCUS_STEP_RANGE = [1 255]
        self.FOCUS_DIRECT_RANGE = self.getFocusRange()

        print(self.status())

    def snapPhoto(self ImageSize=None):
        if ImageSize and ImageSize in self.IMAGE_SIZES:
            stream = urllib.urlopen(self.HTTPLogin +
                                    self.Commands[“snap_photo“].format(
                                        ImageSize[0] ImageSize[1]
                                        self.PhotoIndex))
        else:
            stream = urllib.urlopen(self.HTTPLogin +
                                    self.Commands[“snap_photo“].format(
                                        self.ImageSize[0] self.ImageSize[1]
                                        self.PhotoIndex))
        jpg_bytearray = np.asarray(bytearray(stream.read()) dtype=np.uint8)
        self.Image = cv2.imdecode(jpg_bytearray cv2.CV_LOAD_IMAGE_COLOR)
        self.PhotoIndex += 1
        return self.Image

    def getValue(self Text):
        Text = Text.split(“=“)
        TextValue = re.sub(“‘“ ““ Text[1])
        ValueList = Text

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-11-24 05:08  ipcamcontrol-master\
     文件         675  2014-11-24 05:08  ipcamcontrol-master\.gitignore
     文件       35122  2014-11-24 05:08  ipcamcontrol-master\LICENSE
     文件         145  2014-11-24 05:08  ipcamcontrol-master\README.md
     文件       11265  2014-11-24 05:08  ipcamcontrol-master\ipcamcontrol.py

评论

共有 条评论

相关资源