Fix problem with using JPEG images as a source.

Now vpudec is not used by default to decode JPEG images.

Change-Id: I40896c5967bf1734748ded913edb19ca9faf34cc
diff --git a/edgetpuvision/gstreamer.py b/edgetpuvision/gstreamer.py
index bd3cc5e..d2ebe95 100644
--- a/edgetpuvision/gstreamer.py
+++ b/edgetpuvision/gstreamer.py
@@ -93,6 +93,8 @@
     return (
         Filter('filesrc', location=filename),
         Filter('decodebin'),
+        Filter('videoconvert'),
+        Caps('video/x-raw', format='RGB'),
         Filter('imagefreeze'),
         Tee(pads=((
             Queue(max_size_buffers=1),
@@ -347,6 +349,11 @@
         fullscreen=fullscreen)
 
 def run(inference_size, render_overlay, *, source, downscale, fullscreen):
+    reg = Gst.Registry.get()
+    for feature in reg.get_feature_list_by_plugin('vpu.imx'):
+        # Otherwise decodebin uses vpudec to decode JPEG images and fails.
+        feature.set_rank(Gst.Rank.MARGINAL)
+
     fmt = parse_format(source)
     if fmt:
         run_camera(inference_size, render_overlay, fmt, fullscreen)
@@ -374,7 +381,6 @@
 
 def run_file(inference_size, render_overlay, *, filename, downscale, fullscreen):
     inference_size = Size(*inference_size)
-
     info = get_video_info(filename)
     render_size = Size(info.get_width(), info.get_height()) / downscale
     if info.is_image():