Beispiel #1
0
def camera_connection(ip, user, password):
    try:
        connected_camera = Client('http://' + ip, user, password)
        return connected_camera
    except:
        print("XML bağlantı yolunu kontrol et!")
        return 0
Beispiel #2
0
 def __init__(self, args: argparse.Namespace,
              logger: logging.Logger) -> None:
     super().__init__(args, logger)
     self.snapshot_dir = tempfile.mkdtemp()
     self.streams = {}
     self.cam = Client(f"http://{self.args.ip}", self.args.username,
                       self.args.password)
Beispiel #3
0
def main():
    global client, host, username, password, channel

    load_parameters()
    try:
        client = Client(host, username, password)
    except:
        print("Could not connect to remote host.")
    grid = ScreenGrid.ScreenGrid(2, 2)

    chans = []

    for counter, channel in enumerate(channels):
        chans.append(Channel.Channel(channel, counter, client, grid))

    while True:
        for chan in chans:
            chan.run()
            time.sleep(1)

        for event in pygame.event.get():
            if (event.type == pygame.KEYUP and event.key == pygame.K_c
                    and event.mod & pygame.KMOD_CTRL):
                pygame.quit()
                sys.exit()
Beispiel #4
0
 def __init__(self, args, logger=None):
     self.logger = logger
     self.args = args
     self.dir = tempfile.mkdtemp()
     self.streams = {}
     self.cam = Client(
         "http://{}".format(self.args.ip), self.args.username, self.args.password
     )
Beispiel #5
0
 def __init__(self,
              host_url,
              user='******',
              pwd='password123',
              flip=False,
              manual_override=None):
     self.api = Client(host_url, user, pwd)
     self.flip = flip
     self.manual_override = manual_override
            outfile = logging.getLogger('hikevents_logger')
            outfile.setLevel(logging.INFO)
            outfile_handler = logging.handlers.RotatingFileHandler(
                config.LOGFILE,
                mode="a",
                maxBytes=(config.LOGMAXSIZE),
                backupCount=config.LOGMAXBACKUPS)
            outfile.addHandler(outfile_handler)
            print(f"Writing logfile to {config.LOGFILE}")

        log_msg = 'Logging started at: ' + str(
            datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
        hikevents_logger(log_msg)
        hikevents_logger('Connecting to Hikvision NVR...')
        try:
            nvr = Client(config.IPADDR, config.USER, config.PASS)
            hikevents_logger('Monitoring for events from NVR @ http://' +
                             config.IPADDR)
            nvrinfo = nvr.System.deviceInfo(method='get')
            hikevents_logger('  Name: ' + nvrinfo['DeviceInfo']['deviceName'])
            hikevents_logger('  Serial: ' +
                             nvrinfo['DeviceInfo']['serialNumber'])
            hikevents_logger('  Model: ' + nvrinfo['DeviceInfo']['model'])
            hikevents_logger('  Firmware: ' +
                             nvrinfo['DeviceInfo']['firmwareVersion'])
            hikevents_logger('  Cameras: ')
            for i in range(8):
                hikevents_logger('    ' + str(i + 1) + ') ' + config.CAMERA[i])
        except:
            hikevents_logger('ERROR: Hikvision NVR not found!')
            sys.exit()
Beispiel #7
0

# Encoding images -----------------------------------------------------
print("Start processing faces...")
processing_face_data.crop_faces()
print("Start encoding faces...")
processing_face_data.encode_faces()
print("Prepare data done")
# Loading database ----------------------------------------------------

with open("encode_face.pkl", "rb") as f:
    data = pickle.load(f)
    x, y = data["x"], data["y"]
print("Loaded database")
# Start stream
cam = Client(CAM_IP, CAM_USER, CAM_PASS , timeout=30)
while(True):
    response = cam.Streaming.channels[102].picture(method='get', type='opaque_data')

    raw = response.raw.read()
    stream = BytesIO(raw)
    image = Image.open(stream).convert("RGB")
    open_cv_image = np.array(image)
    name, acc, x_pos, y_pos, w, h = face_recognition.recogition(x, y, open_cv_image)
    #name, acc = None, 1
    # Convert RGB to BGR 
    open_cv_image = open_cv_image[:, :, ::-1].copy() 
    # Put name
    if name and acc >= 0.9:
        open_cv_image = cv2.putText(
            open_cv_image, 
 def __init__(self, args, logger=None):
     super().__init__(args, logger)
     self.snapshot_dir = tempfile.mkdtemp()
     self.streams = {}
     self.cam = Client(f"http://{self.args.ip}", self.args.username,
                       self.args.password)
Beispiel #9
0
from hikvisionapi import Client

cam = Client('http://192.168.1.2', 'admin', 'DeMS2018')

response = cam.System.deviceInfo(method='get')

print(type(response))
print(response)

motion_detection_info = cam.System.Video.inputs.channels[1].motionDetection(
    method='get')

print(motion_detection_info)

# Get and save picture from camera
response = cam.Streaming.channels[1].picture(method='get', type='opaque_data')
print(type(response))
print(response)
print('Here comes the iter')
with open('./screen.jpg', 'wb') as f:
    for chunk in response.iter_content(chunk_size=1024):
        print(chunk)
        if chunk:
            f.write(chunk)