<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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for python_sscma-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18bf7804c8606c1e4fb190d8f7501d96dd8114c61746263b69f569a1717d4737 |
|
MD5 | 50bf6e5243fa30803b2d9706bce45ee5 |
|
BLAKE2b-256 | a4de4ad8ca086043963834b0c0977679fd20fdd16425d8ec8c8b63fe8eef56db |