コード例 #1
0
 def __setMotionAlarm(self, status):
     url = self.base_url + "set_alarm.cgi?motion_armed=" + ` status ` + "&user="******"&pwd=" + urllib2.quote(self.password)
     result = urllib2.urlopen(url).read()
     result = result.strip()
     if result != "ok.":
         raise CamController.CamControllerError(result,
                                                inspect.stack()[0][3],
                                                self.ip_address)
     return
コード例 #2
0
    def __sendURL(self, url):
        try:
            f = urllib.urlopen(url)

            if f.getcode() != 200:
                raise CamController.CamControllerError(
                    "Bad HTTP Response from Camera", f.getcode(),
                    inspect.stack()[0][3])

            lines = []
            for line in f:
                lines.append(line.strip())
            f.close()

            if lines[0].find("var") < 0:
                raise CamController.CamControllerError("".join(lines),
                                                       inspect.stack()[0][3])
        except IOError as e:
            raise CamController.CamControllerError(e.args)

        return self.__parseLines(lines)
コード例 #3
0
    def __sendURL(self,url):
        try:
            f=urllib.urlopen(url)

            if f.getcode()!=200:
                raise CamController.CamControllerError("Bad HTTP Response from Camera",f.getcode(),url,inspect.stack()[0][3])
    
            lines=[]
            for line in f:            
                lines.append(line.strip())
            f.close()
        except IOError as e:
            raise CamController.CamControllerError(e.args)
        
        if lines[0] == "<CGI Result>":
            raise CamController.CamControllerError("Bad Result from Camera",inspect.stack()[0][3])

        result=self.__parseLines(lines)
        
        if int(result['result'])!=0:
            raise CamController.CamControllerError("Non-Zero Response from Camera",result,inspect.stack()[0][3])
        
        return result
コード例 #4
0
 def __init__(self,maker,model,ip_address,port,user,password,alarm):
     self.maker=maker
     self.model=model
     self.ip_address=ip_address
     self.port=port
     self.user=user
     self.password=password
     self.alarm=alarm
     self.base_url="http://" + self.ip_address + ":" + self.port + "/"
     
     if not self.isAdmin():
         raise CamController.CamControllerError("Configured User must be an admin",inspect.stack()[0][3])
     
     self.cam_name=self.__getCamName()
コード例 #5
0
    def __sendURL(self, url):
        tries = 0
        while tries <= self.max_retries:
            try:
                f = urllib2.urlopen(url, None, CamController.TIME_OUT)
                break
            except IOError as e:
                tries += 1
        else:
            raise CamController.CamControllerError(e.args,
                                                   inspect.stack()[1][3],
                                                   self.ip_address)

        if f.getcode() != 200:
            raise CamController.CamControllerError(
                "Bad HTTP Response from Camera", f.getcode(),
                inspect.stack()[1][3], self.ip_address)

        lines = []
        tries = 0
        while tries <= self.max_retries:
            try:
                lines = f.readlines()
                break
            except Exception as e:
                tries += 1
        else:
            raise CamController.CamControllerError(e.args,
                                                   inspect.stack()[1][3],
                                                   self.ip_address)

        if not lines or lines[0].find("var") < 0:
            raise CamController.CamControllerError("".join(lines),
                                                   inspect.stack()[1][3],
                                                   self.ip_address)

        return self.__parseLines(lines)
コード例 #6
0
    def __init__(self, maker, model, ip_address, port, user, password, alarm):
        self.maker = maker
        self.model = model
        self.ip_address = ip_address
        self.port = port
        self.user = user
        self.password = password
        self.alarm = alarm

        if not self.isAdmin():
            raise CamController.CamControllerError(
                "Configured User must be an admin",
                inspect.stack()[0][3])

        self.base_url = "http://" + self.user + ":" + self.password + "@" + self.ip_address + ":" + self.port + "/web/cgi-bin/hi3510/"
        url = self.base_url + "param.cgi?cmd=getosd&-chn=1&-region=1"
        self.cam_name = self.__sendURL(url)['name']
コード例 #7
0
def main():
    global ids
    global corners
    global rvec
    global tvec
    global myur
    global cam
    global rob

    rob = urx.Robot("10.0.2.64")
    rob.set_tcp((0, 0, 0, 0, 0, 0))

    myur = UrController.MyUR()
    cam = CamController.cam()

    if (cam.doOperation() != 0):
        ids, corners, rvec, tvec = cam.doOperation()
        print(tvec)