Skip to main content

Camera connections and socket utils

Project description

Installation

Responsitory Github page

- Install from local responsitory:
1.Clone Responsitory
2.cd folder\
3.pip install -e .\

Camera

Basler

Using open Basler camera Reference pypylon master

from connections import Basler
# init camera
camera = Basler()
# open camera by index 0
camera.open(0)
# open camera by serinumber
# camera.open('serinumber_here')
# grab image
mat = camera.grab()
print(mat.shape)
# close camera
camera.close()

Webcam

Using open Webcam or RTSP camera
Reference opencv video capture

from connections import Webcam
# init camera
camera = Webcam()

# open camera by rtsp
# camera.open('rtsp_link_here')
# open camera by index 0
camera.open(0)

# grab image
mat = camera.grab()
print(mat.shape)

# close camera
camera.close()

Socket utils

Some function help send image(numpy array) or text over socket client and server

import socket
import numpy as np
from connections.socket_utils import send_text, send_image

sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sk.connect(("localhost", 5000))

# send text with length with format: {lenth}:text:{your_text}
# ex client send "Hello", server revcieve "5:text:Hello"
msg = time.strftime("Client sent %H:%M:%S\n")
send_text(sk, msg)

# send array with length with format: {lenth}:image:{your_array_encode}
mat = np.random.radnint(0, 256, (640, 480, 3))
send_image(sk, mat)

Logger

Custom logger
Reference Logger console with color
Reference Logging CookBook

from connections import Logger
logger = Logger(name="mylog", 
            file_name="logfile.log", 
            file_level=logging.INFO,
            stream_level=logging.INFO)
logger.info("this is info")
logger.warning("this is warning")
logger.error("this is error")
logger.critical("this is critical")

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

nammv-1.0.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

nammv-1.0.0-py3-none-any.whl (6.2 kB 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