What is the experience of running the algorithm in a black box? Front-end rstp pull flow

what is black box

When I first got this thing, I had no experience in using it at all, so I was very confused
when I saw it. Later, I borrowed a display screen, a set of wireless mouse and keyboard, powered on the box, and connected it to the Internet cable
to see that it is actually equivalent to a complete computer. The linux system (the board is nx)
and then run the written algorithm in this system

install python

Linux generally comes with python, you can check the version of python according to the following command

python --versin
python
python3

install opencv

Enter the following command to install opencv, the download may fail due to network speed problems

pip3 install opencv-python

You can switch to mirror source download, enter the following command

pip3 install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple

During the download process, I encountered a problem: I was stuck at
the beginning of building and found that cython was not installed, but it was still unsuccessful. The
later solution was: download the .whl file of the nx version, and manually place it in the python3 library, bingo!

Check if the installation is successful

python3
import cv2
cv2.__version__

Python pulls Hikvision camera rtsp stream

Reference link: Python calls the Hikvision network camera - python reads the camera rtsp stream to display the screen
Reference link: Python pulls the Hikvision camera rtsp stream - suitable for Xiaobai

Haikang IPcamera rtsp address and format:
rtsp://[username]:[password]@[ip]:[port]/[codec]/[channel]/[subtype]/av_stream

Description:
username: username. For example admin.
password: Password. For example 12345.
ip: It is the IP of the device. For example 192.0.0.64.
port: The port number is 554 by default, if it is the default, it can be left blank.
codec: There are h264, MPEG-4, and mpeg4.
channel: channel number, starting from 1. For example, channel 1 is ch1.
subtype: stream type, the main stream is main, and the auxiliary stream is sub.

Pull the media stream by modifying the ip address, user name, and password.

import cv2
ip='192.168.2.111'
user='admin'
password='123456'
cap = cv2.VideoCapture("rtsp://"+ user +":"+ password +"@" + ip + ":554/h264/ch1/main/av_stream")
ret, frame = cap.read()
cv2.namedWindow(ip,0)
cv2.resizeWindow(ip,500,300)
while ret:
    ret, frame = cap.read()
    cv2.imshow(ip,frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cv2.destroyAllWindows()
cap.release()

After calling the camera data, the detection is realized through the algorithm

algorithm

slightly

Alarm Output

Use the algorithm to detect the video stream of the rtsp pull stream, and output the alarm signal to the server
Here, in order to check whether the alarm output is successful,
build a virtual server through fpt,
​​see the next article

Guess you like

Origin blog.csdn.net/qq_34885993/article/details/126500459