Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config-jetson.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[App]
VideoPath: /repo/data/TownCentreXVID.avi
VideoPath: /dev/video0
Host: 0.0.0.0
Port: 8000
Resolution: 640,480
Expand Down
10 changes: 7 additions & 3 deletions jetson-nano.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand All @@ -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

Expand Down
33 changes: 32 additions & 1 deletion libs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down
2 changes: 2 additions & 0 deletions neuralet-distancing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down