bdtinc / maskcam Goto Github PK
View Code? Open in Web Editor NEWJetson Nano-based smart camera system that measures crowd face mask usage in real-time.
License: MIT License
Jetson Nano-based smart camera system that measures crowd face mask usage in real-time.
License: MIT License
There seems to be a threshold of maximum face size, when I get close enough to the camera seems like the detection doesn't see a face. Is there a size guide for the weight of Yolo Detection you are using? Thank you
I would like to build a custom_maskcam container. My goal is to get a better understanding of the architecture of the project and to eventually train my own dataset. Right now I simply cloned the repository on my jetson nano. When I use the command: docker build . -t custom_maskcam inside my maskcam folder I keep getting the same error :
Step 12/28 : RUN export GST_CFLAGS="-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include" && export GST_LIBS="-lgstreamer-1.0 -lgobject-2.0 -lglib-2.0" && git clone https://github.com/GStreamer/gst-python.git && cd gst-python && git checkout 1a8f48a && ./autogen.sh PYTHON=python3 && ./configure PYTHON=python3 && make && make install
---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
---> Running in 3eb0f983b6c4
Cloning into 'gst-python'...
Note: checking out '1a8f48a'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b
HEAD is now at 1a8f48a Release 1.14.5
This error occurs when installing gst-python.
Can you help me with this issue.
Thank you
Raphael
Hi,
I'm trying to write a deepstream-app, and I'm not very familiar with Glib.I met a problem before that if the rtsp sources are not stable or the internet is poor, the pipeline will run without any errors as well as any outputs. So I'm trying to find a way to restart the pipeline under this circumstance.
I found your codes and the glib_cb_restart
confused me. I read your annotations, so the timeout_add
will call glib_cb_restart
and without a return value, the function will add another timeout_add
. Your annotation said:Timer to avoid GLoop locking infinitely and But we want to check periodically for other events. I also found the explanation about Glib.MainContext.iteration.
I don't get the point of the usage of this function.
Appreciate if you can explain a little more or give me some hints.
Thanks a lot
With the newer DeepStream 6.0 supporting Redis, is it possible to implement Redis as a backend database for maskcam.
When I tried to reproduce the project, I encountered a problem that the container (server_streamlit)could not start. I tried to unload the container and rebuild it through image, but I still couldn't start it successfully. Its state has always been:Exited(1). I checked its log, as shown below:
Traceback (most recent call last):
File "/usr/local/bin/streamlit", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/streamlit/cli.py", line 233, in main_run
_main_run(target, args)
File "/usr/local/lib/python3.7/site-packages/streamlit/cli.py", line 249, in _main_run
command_line = _get_command_line_as_string()
File "/usr/local/lib/python3.7/site-packages/streamlit/cli.py", line 244, in _get_command_line_as_string
cmd_line_as_list.extend(click.get_os_args())
AttributeError: module 'click' has no attribute 'get_os_args'
Receiving your reply is of great help to me!
Can adding rtsp input ? For ipcam ?
I am getting this error
python3 maskcam_run.py
| DEBUG Using selector: EpollSelector selector_events.py:54
INFO maskcam-run | Using input from config file: prints.py:48
v4l2:///dev/video0
WARNING maskcam-run | MQTT is DISABLED since MQTT_BROKER_IP or prints.py:44
MQTT_DEVICE_NAME env vars are not defined
INFO maskcam-run | Press Ctrl+C to stop all processes prints.py:48
INFO maskcam-run | Process file-server started with PID: prints.py:48
12650
INFO maskcam-run | Starting streaming prints.py:48
(streaming-start-default is set)
INFO maskcam-run | Received command: streaming_start prints.py:48
INFO maskcam-run | Process inference started with PID: 12652 prints.py:48
INFO maskcam-run | Processing command: streaming_start prints.py:48
INFO maskcam-run | Process streaming started with PID: 12653 prints.py:48
INFO mqtt | MQTT not connected. Skipping message to topic: prints.py:48
device-status
| INFO file-server | Serving static files from directory: prints.py:48
/tmp/saved_videos
INFO file-server | Static server STARTED at prints.py:48
http://:8080
| INFO streaming | Codec: H264 prints.py:48
INFO streaming | prints.py:48
Streaming at
rtsp://<device-address-not-configured>:8554/maskcam
| INFO inference | Auto calculated frames to skip inference: 2 prints.py:48
INFO inference | Creating Pipeline prints.py:48
INFO inference | Creating Camera input prints.py:48
INFO inference | Creating Convertor src 2 prints.py:48
INFO inference | Creating Camera caps filter prints.py:48
INFO inference | Creating Convertor src 1 prints.py:48
INFO inference | Creating NVMM caps for input stream prints.py:48
INFO inference | Creating NvStreamMux prints.py:48
INFO inference | Creating pgie prints.py:48
INFO inference | Creating Converter NV12->RGBA prints.py:48
INFO inference | Creating OSD (nvosd) prints.py:48
INFO inference | Creating Queue prints.py:48
INFO inference | Creating Converter RGBA->NV12 prints.py:48
INFO inference | Creating capsfilter prints.py:48
INFO inference | Creating H264 stream prints.py:48
INFO inference | Creating Encoder prints.py:48
INFO inference | Creating Code Parser prints.py:48
INFO inference | Creating RTP H264 Payload prints.py:48
INFO inference | Creating Splitter file/UDP prints.py:48
INFO inference | Creating UDP queue prints.py:48
INFO inference | Creating Multi UDP Sink prints.py:48
INFO inference | Creating Fake Sink prints.py:48
INFO inference | Linking elements in the Pipeline prints.py:48
Opening in BLOCKING MODE
Opening in BLOCKING MODE
ERROR: Deserialize engine failed because file path: /home/jetsonnano/maskcam/yolo/maskcam_y4t_1024_608_fp16.trt open error
0:00:02.575327981 12652 0x200a86f0 WARN nvinfer gstnvinfer.cpp:616:gst_nvinfer_logger: NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1691> [UID = 1]: deserialize engine from file :/home/jetsonnano/maskcam/yolo/maskcam_y4t_1024_608_fp16.trt failed
0:00:02.575399128 12652 0x200a86f0 WARN nvinfer gstnvinfer.cpp:616:gst_nvinfer_logger: NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:1798> [UID = 1]: deserialize backend context from engine from file :/home/jetsonnano/maskcam/yolo/maskcam_y4t_1024_608_fp16.trt failed, try rebuild
0:00:02.575429806 12652 0x200a86f0 INFO nvinfer gstnvinfer.cpp:619:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1716> [UID = 1]: Trying to create engine from model files
Yolo type is not defined from config file name:
ERROR: Failed to create network using custom network creation function
ERROR: Failed to get cuda engine from custom library API
0:00:02.575762260 12652 0x200a86f0 ERROR nvinfer gstnvinfer.cpp:613:gst_nvinfer_logger: NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1736> [UID = 1]: build engine file failed
0:00:02.575795021 12652 0x200a86f0 ERROR nvinfer gstnvinfer.cpp:613:gst_nvinfer_logger: NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:1822> [UID = 1]: build backend context failed
0:00:02.575826220 12652 0x200a86f0 ERROR nvinfer gstnvinfer.cpp:613:gst_nvinfer_logger: NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1149> [UID = 1]: generate backend failed, check config file settings
0:00:02.576405397 12652 0x200a86f0 WARN nvinfer gstnvinfer.cpp:812:gst_nvinfer_start: error: Failed to create NvDsInferContext instance
0:00:02.576446544 12652 0x200a86f0 WARN nvinfer gstnvinfer.cpp:812:gst_nvinfer_start: error: Config file path: maskcam_config.txt, NvDsInfer Error: NVDSINFER_CONFIG_FAILED
ERROR inference | gst-resource-error-quark: Failed to create prints.py:42
NvDsInferContext instance (1): /dvs/git/dirty/git-master
_linux/deepstream/sdk/src/gst-plugins/gst-nvinfer/gstnvi
nfer.cpp(812): gst_nvinfer_start ():
/GstPipeline:pipeline0/GstNvInfer:primary-inference:
Config file path: maskcam_config.txt, NvDsInfer Error:
NVDSINFER_CONFIG_FAILED
INFO inference | prints.py:48
TROUBLESHOOTING HELP
If the error is like: v4l-camera-source / reason
not-negotiated
Solution: configure camera capabilities
Run the script under utils/gst_capabilities.sh and
find the lines with type
video/x-raw ...
Find a suitable framerate=X/1 (with X being an
integer like 24, 15, etc.)
Then edit config_maskcam.txt and change the line:
camera-framerate=X
Or configure using --env MASKCAM_CAMERA_FRAMERATE=X
(see README)
If the error is like:
/usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot
allocate memory in static TLS block
Solution: preload the offending library
export
LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1
END HELP
INFO inference | Inference main loop ending. prints.py:48
INFO maskcam-run | Sending interrupt to file-server process prints.py:48
INFO file-server | Shutting down static file server prints.py:48
INFO maskcam-run | Waiting for process file-server to prints.py:48
terminate...
INFO file-server | Server shut down correctly prints.py:48
INFO file-server | Server alive threads: prints.py:48
[<_MainThread(MainThread, started 548193665040)>]
INFO maskcam-run | Process terminated: file-server prints.py:48
INFO maskcam-run | Sending interrupt to streaming process prints.py:48
INFO maskcam-run | Waiting for process streaming to prints.py:48
terminate...
INFO streaming | Ending streaming prints.py:48
INFO maskcam-run | Process terminated: streaming prints.py:48
Hi, Instead of using usb web cam or mp4 file, I am wondering whether a RTMP or HLS video feed can be used as an input source. Any hint is given to modify the python script? Thanks.
After I got the server set up on my local machine, I want use Jetson Nano to run following command:
sudo docker run --runtime nvidia --privileged --rm -it --env MQTT_BROKER_IP= --env MQTT_DEVICE_NAME=my-jetson-1 --env MASKCAM_DEVICE_ADDRESS= -p 1883:1883 -p 8080:8080 -p 8554:8554 maskcam/maskcam-beta
but I can't establish MQTT connection from the device to the server, than I use Jetson Nano try following command:
ping
I found I can't ping my local server IP
How to fix this problem?
standard_init_linux.go:219: exec user process caused: exec format error The command '/bin/sh -c python -m pip install --upgrade pip && pip install -r requirements.txt' returned a non-zero code: 1 ERROR: Service 'backend' failed to build : Build failed
I followed the instructions given in this section Running the MQTT Broker and Web Server and I did all steps; however, I couldn't run the web server it gives me some errors(see the attached picture). I tried to refresh the webpage and no use. What you think I am doing wrong here?
FYI: I am running the web server on another laptop, not on my jetson nano. I am also using Ubuntu 20.4
Hello,
I want to test maskcam on Jetson Xavier NX.
Could your share the raw weights file (facemask-yolov4-tiny_best.weights, maskcam-yolov4-best.weights?), so as to "Convert weights generated using the original darknet implementation to TRT" (in https://github.com/bdtinc/maskcam/blob/main/docs/Useful-Development-Scripts.md)
This seems to be a necessary procedure to test maskcam on Jetson Xavier NX.
Thank you in advance
HI,professor:
this project very good, but in practical use , we prefer C++, so, can realize with C++, thanks !
can someone paste the link
Hi Guys, amazing work. It's just that when I check the time visible in the web report, it's showing incorrectly. Both my web server and jetson nano are already on my timezone: GMT+7. Where can I set the timezone?
I am trying to deploy the application without Docker. Seem to be running in to the problem of compiling YOLOv4 plugin for Deepstream. After cd <this repo path>/deepstream_plugin_yolov4
and export CUDA_VER=10.2
I went to execute 'make' next and run to the error: root@seen-desktop:/home/seen/Desktop/maskcam/deepstream_plugin_yolov4# export CUDA_VER=10.2 root@seen-desktop:/home/seen/Desktop/maskcam/deepstream_plugin_yolov4# make g++ -c -o nvdsinfer_yolo_engine.o -Wall -std=c++11 -shared -fPIC -Wno-error=deprecated-declarations -I../../includes -I/usr/local/cuda-10.2/include -I/opt/nvidia/deepstream/deepstream-5.0/sources/includes nvdsinfer_yolo_engine.cpp nvdsinfer_yolo_engine.cpp:23:10: fatal error: nvdsinfer_custom_impl.h: No such file or directory #include "nvdsinfer_custom_impl.h" ^~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. Makefile:51: recipe for target 'nvdsinfer_yolo_engine.o' failed make: *** [nvdsinfer_yolo_engine.o] Error 1
Hello,
I am having trouble understanding the procedure to train my own detection model. I have a Jetson Nano 2GB and 4GB variant with me.
My objective is to detect if a person wears sunglasses or not. To accomplish this objective, my main queries are as follows.
My work flow is the exact same as mask cam, with remote deployment and web server accessing and the rest. I just need to change the object detection mechanism. Even the statistics that it provides will be unchanged.
Thank you.
Hello, I tried to install the project without the Docker container as indicated in "Installing MaskCam Manually (Without a Container)" but I get the following error
dlinano@dlinano-desktop:~/maskcam$ python3 maskcam_run.py
Traceback (most recent call last):
File "maskcam_run.py", line 72, in
from maskcam.maskcam_inference import main as inference_main
File "/home/dlinano/maskcam/maskcam/maskcam_inference.py", line 41, in
gi.require_version("GstRtspServer", "1.0")
File "/usr/lib/python3/dist-packages/gi/init.py", line 130, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace GstRtspServer not available
I'm trying to run it on the Jetson nano, the Docker Container version works fine for me.
How to add a video file rather than live stream from camera device for Mask detection?
`Opening in BLOCKING MODE
ERROR: [TRT]: INVALID_CONFIG: The engine plan file is generated on an incompatible device, expecting compute 7.2 got compute 5.3, please rebuild.
ERROR: [TRT]: engine.cpp (1546) - Serialization Error in deserialize: 0 (Core engine deserialization failure)
ERROR: [TRT]: INVALID_STATE: std::exception
ERROR: [TRT]: INVALID_CONFIG: Deserialize the cuda engine failed.
ERROR: Deserialize engine failed from file: /opt/maskcam_1.0/yolo/maskcam_y4t_1024_608_fp16.trt
0:00:03.391191797 89 0x1cf0fd00 WARN nvinfer gstnvinfer.cpp:616:gst_nvinfer_logger: NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1690> [UID = 1]: deserialize engine from file :/opt/maskcam_1.0/yolo/maskcam_y4t_1024_608_fp16.trt failed
0:00:03.391251448 89 0x1cf0fd00 WARN nvinfer gstnvinfer.cpp:616:gst_nvinfer_logger: NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:1797> [UID = 1]: deserialize backend context from engine from file :/opt/maskcam_1.0/yolo/maskcam_y4t_1024_608_fp16.trt failed, try rebuild
0:00:03.391282234 89 0x1cf0fd00 INFO nvinfer gstnvinfer.cpp:619:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1715> [UID = 1]: Trying to create engine from model files
Yolo type is not defined from config file name:
ERROR: Failed to create network using custom network creation function
ERROR: Failed to get cuda engine from custom library API
0:00:03.391650410 89 0x1cf0fd00 ERROR nvinfer gstnvinfer.cpp:613:gst_nvinfer_logger: NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1735> [UID = 1]: build engine file failed
0:00:03.391677900 89 0x1cf0fd00 ERROR nvinfer gstnvinfer.cpp:613:gst_nvinfer_logger: NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:1821> [UID = 1]: build backend context failed
0:00:03.391722606 89 0x1cf0fd00 ERROR nvinfer gstnvinfer.cpp:613:gst_nvinfer_logger: NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1148> [UID = 1]: generate backend failed, check config file settings
0:00:03.392212548 89 0x1cf0fd00 WARN nvinfer gstnvinfer.cpp:809:gst_nvinfer_start: error: Failed to create NvDsInferContext instance
0:00:03.392239590 89 0x1cf0fd00 WARN nvinfer gstnvinfer.cpp:809:gst_nvinfer_start: error: Config file path: maskcam_config.txt, NvDsInfer Error: NVDSINFER_CONFIG_FAILED
ERROR inference | gst-resource-error-quark: Failed to create NvDsInferContext instance (1): /dvs/git/dirty/git-master_linux/deepstream/sdk/src/gst-plugins/gst-nvinfer/gstnvinfer.cpp(809): prints.py:42
gst_nvinfer_start (): /GstPipeline:pipeline0/GstNvInfer:primary-inference:
Config file path: maskcam_config.txt, NvDsInfer Error: NVDSINFER_CONFIG_FAILED
INFO inference | prints.py:48
TROUBLESHOOTING HELP
If the error is like: v4l-camera-source / reason not-negotiated
Solution: configure camera capabilities
Run the script under utils/gst_capabilities.sh and find the lines with type
video/x-raw ...
Find a suitable framerate=X/1 (with X being an integer like 24, 15, etc.)
Then edit config_maskcam.txt and change the line:
camera-framerate=X
Or configure using --env MASKCAM_CAMERA_FRAMERATE=X (see README)
If the error is like:
/usr/lib/aarch64-linux-gnu/libgomp.so.1: cannot allocate memory in static TLS block
Solution: preload the offending library
export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1
END HELP
INFO inference | Inference main loop ending. prints.py:48
INFO inference | Output file saved: output_Robot.mp4 prints.py:48
INFO maskcam-run | Sending interrupt to streaming process prints.py:48
INFO maskcam-run | Waiting for process streaming to terminate... prints.py:48
INFO streaming | Ending streaming prints.py:48
INFO maskcam-run | Process terminated: streaming prints.py:48
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.