Skip to main content

<INSERT_DESCRIPTION>

Project description

Python SSCMA-Micro

Description

This is a client for the sscma_micro, which is a microcontroller at server for the SSCMA models.

More information about the sscma_micro can be found at here

Usage

Install

pip install python-sscma
from sscma.micro.client import Client, SerialClient
from sscma.micro.device import Device
from sscma.micro.const import *
import serial
import threading
import time
import logging
import signal
import cv2
import base64
import numpy as np

logging.basicConfig(level=logging.DEBUG)

_LOGGER = logging.getLogger(__name__)


def monitor_handler(device, msg):
    if "image" in msg:
        jpeg_bytes = base64.b64decode(msg["image"])

        # Convert the bytes into a numpy array
        nparr = np.frombuffer(jpeg_bytes, np.uint8)

        # Decode the image array using OpenCV
        img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)

        # Display the image
        cv2.imshow('Base64 Image', img)
        cv2.waitKey(1)
        msg.pop("image")
    print(msg)


def on_device_connect(device):
    print("device connected")
    device.Invoke(-1, False, True)
    device.tscore = 70
    device.tiou = 70


client = SerialClient("COM83")

def signal_handler(signal, frame):
    print("Ctrl+C pressed!")
    client.loop_stop()
   
def main():

    signal.signal(signal.SIGINT, signal_handler)
 
    device = Device(client)

    device.on_monitor = monitor_handler
    device.on_connect = on_device_connect
     
    device.loop_start()

    print(device.info)

    i = 60

    while True:
        print(device.wifi)
        print(device.mqtt)
        print(device.info)
        print(device.model)
        device.tscore = i
        device.tiou = i
        i = i + 1
        if i > 100:
            i = 30

        time.sleep(2)


if __name__ == "__main__":
    main()

Contributing

If you have any idea or suggestion, please open an issue first.

If you want to contribute code, please fork this repository and submit a pull request.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-sscma-0.2.1.tar.gz (1.0 MB view hashes)

Uploaded Source

Built Distribution

python_sscma-0.2.1-py3-none-any.whl (1.0 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page