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
7 changes: 6 additions & 1 deletion gstreamer/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ def main():
parser.add_argument('--tracker', help='Name of the Object Tracker To be used.',
default=None,
choices=[None, 'sort'])
parser.add_argument('--height', type=int, help='Video height.',
default=480)
parser.add_argument('--width', type=int, help='Video width.',
default=640)

args = parser.parse_args()

print('Loading {} with {} labels.'.format(args.model, args.labels))
Expand Down Expand Up @@ -207,7 +212,7 @@ def user_callback(input_tensor, src_size, inference_box, mot_tracker):
return generate_svg(src_size, inference_size, inference_box, objs, labels, text_lines, trdata, trackerFlag)

result = gstreamer.run_pipeline(user_callback,
src_size=(640, 480),
src_size=(args.width, args.height),
appsink_size=inference_size,
trackerName=args.tracker,
videosrc=args.videosrc,
Expand Down
5 changes: 4 additions & 1 deletion gstreamer/gstreamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ def run_pipeline(user_function,
else:
SRC_CAPS = 'video/x-raw,width={width},height={height},framerate=30/1'
if videosrc.startswith('/dev/video'):
PIPELINE = 'v4l2src device=%s ! {src_caps}'%videosrc
if videofmt == 'jpeg':
PIPELINE = 'v4l2src device=%s ! {src_caps} ! jpegdec ! videoconvert' % videosrc
else:
PIPELINE = 'v4l2src device=%s ! {src_caps}' % videosrc
elif videosrc.startswith('http'):
PIPELINE = 'souphttpsrc location=%s'%videosrc
elif videosrc.startswith('rtsp'):
Expand Down
19 changes: 12 additions & 7 deletions gstreamer/install_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if [ "$1" == '-y' ]; then
APT_FORCE="-y"
IGNORE_SORT="yes"
fi

if grep -s -q "MX8MQ" /sys/firmware/devicetree/base/model; then
echo "Installing DevBoard specific dependencies"
sudo apt-get install -y python3-pip python3-edgetpuvision
sudo python3 -m pip install svgwrite
else
# Install gstreamer
sudo apt-get install -y gstreamer1.0-plugins-bad gstreamer1.0-plugins-good python3-gst-1.0 python3-gi gir1.2-gtk-3.0
sudo apt-get install "$APT_FORCE" gstreamer1.0-plugins-bad gstreamer1.0-plugins-good python3-gst-1.0 python3-gi gir1.2-gtk-3.0
python3 -m pip install svgwrite

if grep -s -q "Raspberry Pi" /sys/firmware/devicetree/base/model; then
echo "Installing Raspberry Pi specific dependencies"
sudo apt-get install python3-rpi.gpio
sudo apt-get install "$APT_FORCE" python3-rpi.gpio
# Add v4l2 video module to kernel
if ! grep -q "bcm2835-v4l2" /etc/modules; then
echo bcm2835-v4l2 | sudo tee -a /etc/modules
Expand All @@ -50,14 +55,14 @@ echo "Note that the trackers have their own licensing, many of which
are not Apache. Care should be taken if using a tracker with restrictive
licenses for end applications."

read -p "Install SORT (GPLv3)? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
if [ -z "$IGNORE_SORT" ]; then
read -p "Install SORT (GPLv3)? " -n 1 -r
fi
if [[ "$IGNORE_SORT" = "yes" ]] || [[ "$REPLY" =~ ^[Yy]$ ]]
then
wget https://github.com/abewley/sort/archive/master.zip -O sort.zip
unzip sort.zip -d ../third_party
rm sort.zip
sudo apt install python3-skimage
sudo apt install python3-dev
sudo apt install "$APT_FORCE" python3-skimage python3-dev
python3 -m pip install -r requirements_for_sort_tracker.txt
fi
echo