A package to talk to p2p cameras
Project description
P2PCam
Class to retrieve camera images from cameras using the p2p protocol
First of all i just wrote it to work as a class, the original connection and retrieval process has been made by Jheyman in his videosurveillance script. I rewrote it to run as a class instead of an application.
So i had this chinese camera laying around, it had this feature that you could access it from outside your home without the need for port forwarding. However after a couple of years this brand dissappeared and with it their services so i couldn't connect to it outside of my own network using this app.
Which made owning this camera quite useless. But i had since gotten into Home Asssistant and got the idea to get it working in there since my instance ran locally so it should be able to access the camera.
Usage
import p2pcam
import cv2
import numpy as np
def saveFile(cam, jpeg):
RGBImage = cv2.imdecode(np.fromstring(jpeg, dtype=np.uint8), cv2.IMREAD_COLOR)
cv2.imwrite('image.jpg', RGBImage)
camera = p2pcam.P2PCam(<own ip>, <camera ip>)
saveFile(camera, camera.retrieveImage())
Methods and Variables
Methods
Any methods that may be useful.
camera.initialize()
Set some variables and attempt to connect to the camera for the first time.
camera.retrieveImage()
Retrieve a jpeg string from the camera.
camera.start()
Start a while true loop staying connected, this will not do anything if onJpegReceived
isn't set.
camera.loop()
Start a while loop doing retrieveImage()
until a socket error occurs.
Variables
Some variables you may want to set.
camera.horizontal_flip
Flip camera horizontally. (if true requires numpy and cv2)
camera.vertical_flip
Flip camera vertically. (if true requires numpy and cv2)
camera.addTimeStamp
Add a timestamp to the image. (if true requires numpy and cv2)
camera.debug
If true prints out some debugging information.
The port information will have to be set before initialisation.
camera.UDP_PORT_HOST
Host udp port default: 5123
camera.UDP_PORT_TARGET
Target udp port default: 5000
camera.SOCKET_TIMEOUT
Sets the socket timeout in seconds.
camera.NB_FRAGMENTS_TO_ACCUMULATE
How many packets to get a full image. If you put this number high you will get a higher quality image but it will take longer to retrieve. Default: 80
camera.onJpegReceived
Callback that will be executed if a jpeg image is retrieved. first argument will be the camera class, the second argument will be the jpeg image string.
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
Built Distribution
File details
Details for the file p2pcam-0.0.3.tar.gz
.
File metadata
- Download URL: p2pcam-0.0.3.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41dc6f0f7bc00dd759e5b3585fe090e31e76895e2b3a9a39463a6ddfcaecc1f7 |
|
MD5 | 750ec599edca1eba10475f4cc79452bd |
|
BLAKE2b-256 | 7f5ca868e72cfc476ef765231926e65c3663f9a9661400824ae95e543cc22d11 |
File details
Details for the file p2pcam-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: p2pcam-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a216bef163fd2607c3d48fa96b5399328c23dd2cc05f91465b3e9f1963715ed |
|
MD5 | f74d8b49c2193b6edc5e8fc1b7197ff9 |
|
BLAKE2b-256 | e2d41b87310db96052ea71b1f4c539066d60d9db4eaa1b567c904f16e8a2f58d |