diff --git a/config-jetson.ini b/config-jetson.ini index 3939ed4b..4eb1baa0 100644 --- a/config-jetson.ini +++ b/config-jetson.ini @@ -1,5 +1,5 @@ [App] -VideoPath: /repo/data/TownCentreXVID.avi +VideoPath: /dev/video0 Host: 0.0.0.0 Port: 8000 Resolution: 640,480 diff --git a/jetson-nano.Dockerfile b/jetson-nano.Dockerfile index 8fc24ce8..c1d13f4b 100644 --- a/jetson-nano.Dockerfile +++ b/jetson-nano.Dockerfile @@ -6,7 +6,7 @@ FROM nvcr.io/nvidia/l4t-base:r32.3.1 ENV TZ=US/Pacific -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && printf $TZ > /etc/timezone RUN wget https://github.com/Tony607/jetson_nano_trt_tf_ssd/raw/master/packages/jetpack4.3/tensorrt.tar.gz -O /opt/tensorrt.tar.gz RUN tar -xzf /opt/tensorrt.tar.gz -C /usr/local/lib/python3.6/dist-packages/ @@ -21,6 +21,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ cmake \ curl \ git \ + gedit \ gstreamer1.0-plugins-bad \ gstreamer1.0-plugins-good \ gstreamer1.0-plugins-ugly \ @@ -72,6 +73,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ libboost-python-dev \ libboost-thread-dev \ + libgtk2.0-dev \ + python3-tk \ pkg-config \ python3-dev \ python3-matplotlib \ @@ -94,8 +97,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ pkg-config \ && apt-get autoremove -y -ENTRYPOINT ["python3", "neuralet-distancing.py"] -CMD ["--config", "config-jetson.ini"] +# ENTRYPOINT ["python3", "neuralet-distancing.py"] +# CMD ["--config", "config-jetson.ini"] + WORKDIR /repo EXPOSE 8000 diff --git a/libs/core.py b/libs/core.py index 438fc631..80a7b9b7 100755 --- a/libs/core.py +++ b/libs/core.py @@ -126,8 +126,39 @@ def gstreamer_writer(self, feed_name, fps, resolution): raise RuntimeError("Could not open gstreamer output for " + feed_name) return out + def gstreamer_pipeline( + self, + capture_width=640, + capture_height=480, + display_width=640, + display_height=480, + framerate=60, + flip_method=0, + ): + return ( + "nvarguscamerasrc ! " + "video/x-raw(memory:NVMM), " + "width=(int)%d, height=(int)%d, " + "format=(string)NV12, framerate=(fraction)%d/1 ! " + "nvvidconv flip-method=%d ! " + "video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! " + "videoconvert ! " + "video/x-raw, format=(string)BGR ! appsink" + % ( + capture_width, + capture_height, + framerate, + flip_method, + display_width, + display_height, + ) + ) + + def process_video(self, video_uri): - input_cap = cv.VideoCapture(video_uri) + logger.info(f'Before Taking input') + input_cap = cv.VideoCapture(self.gstreamer_pipeline(flip_method=0), cv.CAP_GSTREAMER) + logger.info(f'After Taking input') fps = input_cap.get(cv.CAP_PROP_FPS) if (input_cap.isOpened()): diff --git a/neuralet-distancing.py b/neuralet-distancing.py index 1f31b900..01563c8f 100644 --- a/neuralet-distancing.py +++ b/neuralet-distancing.py @@ -11,7 +11,9 @@ def start_engine(config, video_path): if video_path: from libs.core import Distancing as CvEngine + print('Before config input') engine = CvEngine(config) + print('After config input') engine.process_video(video_path) else: logger.warning('Skipping CVEngine as video_path is not set in config file')