Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

Node-RedでMJPEG  その2:Imagemagickで加工したWEBカメラの結果を表示

実際のところ

もっとスマートな方法はいくらかあったのでしょうが、とりあえず動くものを。

ホスト名は"picam"とします

まず画像の保存先にてシンプルなサーバーを起動

$ python3 -m http.server 8080 --directory /home/pi/


この状態で

[
    {
        "id": "7f2b6b5c.691b64",
        "type": "http in",
        "z": "714eca134aa189b4",
        "name": "",
        "url": "/infinite",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 710,
        "y": 220,
        "wires": [
            [
                "5b3e4039.df33b"
            ]
        ]
    },
    {
        "id": "5b3e4039.df33b",
        "type": "multipart-encoder",
        "z": "714eca134aa189b4",
        "name": "",
        "statusCode": "",
        "ignoreMessages": true,
        "outputOneNew": true,
        "outputIfSingle": true,
        "outputIfAll": true,
        "globalHeaders": {
            "Content-Type": "multipart/x-mixed-replace;boundary=--myboundary",
            "Connection": "keep-alive",
            "Expires": "Fri, 01 Jan 1990 00:00:00 GMT",
            "Cache-Control": "no-cache, no-store, max-age=0, must-revalidate",
            "Pragma": "no-cache"
        },
        "partHeaders": {
            "Content-Type": "image/jpeg"
        },
        "destination": "all",
        "highWaterMark": 16384,
        "x": 906.0000305175781,
        "y": 220.00000095367432,
        "wires": [
            []
        ]
    },
    {
        "id": "4e268ea6ebb3bd7a",
        "type": "exec",
        "z": "714eca134aa189b4",
        "command": "fswebcam -d /dev/video0 -r 640x480 -S 3  --no-banner - | convert - -fill none -stroke red -draw \"rectangle 160,120 320,240\"  -draw \"rectangle 320,120 480,240\"  -draw \"rectangle 160,240 320,360\"  -draw \"rectangle 320,240 480,360\" /home/pi/testImage.png",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "takePic",
        "x": 460,
        "y": 120,
        "wires": [
            [
                "a75949a4238c8ced"
            ],
            [],
            []
        ]
    },
    {
        "id": "907790365f2c7001",
        "type": "inject",
        "z": "714eca134aa189b4",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "3",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 270,
        "y": 120,
        "wires": [
            [
                "4e268ea6ebb3bd7a"
            ]
        ]
    },
    {
        "id": "a75949a4238c8ced",
        "type": "http request",
        "z": "714eca134aa189b4",
        "name": "Get image by url",
        "method": "GET",
        "ret": "bin",
        "paytoqs": "ignore",
        "url": "http://picam.local:8080/testImage.png",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 720,
        "y": 120,
        "wires": [
            [
                "5b3e4039.df33b"
            ]
        ]
    }
]