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.1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nammv-1.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file nammv-1.1.2.tar.gz.

File metadata

  • Download URL: nammv-1.1.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for nammv-1.1.2.tar.gz
Algorithm Hash digest
SHA256 b0a20eb989d9fa6b3f42052862d61b8213eac954fa78e9b4273497f27e080a11
MD5 2665aae0bbc2018deede25ad3c7c32ab
BLAKE2b-256 94973dd3f4dc952d60bd0f54bc8fdb789b6abf6830bc5fc70378bd95773fd902

See more details on using hashes here.

File details

Details for the file nammv-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: nammv-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for nammv-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6d1369423bb8ac4c8e3ca3a17b53f5423dfc2be84f77640643801690c5f71e57
MD5 7a38e6231ea67ee488b9b99157b7489c
BLAKE2b-256 6575518ab0575dc7763a85a5e40cef080bc730b3890099b0ee7b213d3cdb1d1c

See more details on using hashes here.

Supported by

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