summaryrefslogtreecommitdiff
path: root/test/test_esp32_cam.py
blob: 962768f759e1fe0ed224d892175f8c648ebbd771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
import __py_include

from pprint import pprint
from argparse import ArgumentParser
from time import sleep
from homekit.util import Addr
from homekit.camera import esp32
from homekit.config import config

if __name__ == '__main__':
    parser = ArgumentParser()
    parser.add_argument('--addr', type=str, required=True,
                        help='camera server address, in host:port format')
    parser.add_argument('--status', action='store_true',
                        help='print status and exit')

    arg = config.load_app(False, parser=parser)
    cam = esp32.WebClient(addr=Addr.fromstring(arg.addr))

    if arg.status:
        status = cam.getstatus()
        pprint(status)
        sys.exit(0)

    if cam.syncsettings(dict(
        vflip=True,
        hmirror=True,
        framesize=esp32.FrameSize.SVGA_800x600,
        lenc=True,
        wpc=False,
        bpc=False,
        raw_gma=False,
        agc=True,
        gainceiling=5,
        quality=10,
        awb_gain=False,
        awb=True,
        aec_dsp=True,
        aec=True
    )) is True:
        print('some settings were changed, sleeping for 0.5 sec')
        sleep(0.5)

    # cam.setdelay(200)

    cam.setflash(True)
    sleep(0.2)
    cam.capture('/tmp/capture.jpg')
    cam.setflash(False)