title: JPEG parameter struct mismatch: library thinks size is 584, caller expects 728 for python3 in Jetson
body: <p>I am trying to run the darknet_video.py script for YOLO from <a href="https://pysource.com/2019/08/29/yolo-v3-install-and-run-yolo-on-nvidia-jetson-nano-with-gpu/" rel="nofollow noreferrer">here</a></p>
  <p>in Jetson (nano and xavier NX). The code runs fine in one nano but not in another nano and NX. The script is run using the following command in Ubuntu 18.04 (Jetpack)</p>
  <pre><code>python3 darknet_video.py --input test.mp4 --out_filename out1.txt --weights yolov3-tiny.weights --ext_output --config_file yolov3-tiny.cfg --data_file coco.data --thresh 0.2
  </code></pre>
  <p>I am getting the following errors:</p>
  <pre><code>JPEG parameter struct mismatch: library thinks size is 584, caller expects 728
  pure virtual method called
  terminate called without an active exception
  Aborted (core dumped)
  </code></pre>
  <p>Since it runs fine in one nano, it could be dependency issue, here is the code in darknet_video.py</p>
  <pre><code>from ctypes import *
  import random
  import os
  import cv2
  import time
  import darknet
  import argparse
  from threading import Thread, enumerate
  from queue import Queue
  
  
  def parser():
      parser = argparse.ArgumentParser(description=&quot;YOLO Object Detection&quot;)
      parser.add_argument(&quot;--input&quot;, type=str, default=0,
                          help=&quot;video source. If empty, uses webcam 0 stream&quot;)
      parser.add_argument(&quot;--out_filename&quot;, type=str, default=&quot;&quot;,
                          help=&quot;inference video name. Not saved if empty&quot;)
      parser.add_argument(&quot;--weights&quot;, default=&quot;yolov4.weights&quot;,
                          help=&quot;yolo weights path&quot;)
      parser.add_argument(&quot;--dont_show&quot;, action='store_true',
                          help=&quot;windown inference display. For headless systems&quot;)
      parser.add_argument(&quot;--ext_output&quot;, action='store_true',
                          help=&quot;display bbox coordinates of detected objects&quot;)
      parser.add_argument(&quot;--config_file&quot;, default=&quot;./cfg/yolov4.cfg&quot;,
                          help=&quot;path to config file&quot;)
      parser.add_argument(&quot;--data_file&quot;, default=&quot;./cfg/coco.data&quot;,
                          help=&quot;path to data file&quot;)
      parser.add_argument(&quot;--thresh&quot;, type=float, default=.25,
                          help=&quot;remove detections with confidence below this value&quot;)
      return parser.parse_args()
  
  
  def str2int(video_path):
      &quot;&quot;&quot;
      argparse returns and string althout webcam uses int (0, 1 ...)
      Cast to int if needed
      &quot;&quot;&quot;
      try:
          return int(video_path)
      except ValueError:
          return video_path
  
  
  def check_arguments_errors(args):
      assert 0 &lt; args.thresh &lt; 1, &quot;Threshold should be a float between zero and one (non-inclusive)&quot;
      if not os.path.exists(args.config_file):
          raise(ValueError(&quot;Invalid config path {}&quot;.format(os.path.abspath(args.config_file))))
      if not os.path.exists(args.weights):
          raise(ValueError(&quot;Invalid weight path {}&quot;.format(os.path.abspath(args.weights))))
      if not os.path.exists(args.data_file):
          raise(ValueError(&quot;Invalid data file path {}&quot;.format(os.path.abspath(args.data_file))))
      if str2int(args.input) == str and not os.path.exists(args.input):
          raise(ValueError(&quot;Invalid video path {}&quot;.format(os.path.abspath(args.input))))
  
  
  def set_saved_video(input_video, output_video, size):
      fourcc = cv2.VideoWriter_fourcc(*&quot;MJPG&quot;)
      fps = int(input_video.get(cv2.CAP_PROP_FPS))
      video = cv2.VideoWriter(output_video, fourcc, fps, size)
      return video
  
  
  def video_capture(frame_queue, darknet_image_queue):
      while cap.isOpened():
          ret, frame = cap.read()
          if not ret:
              break
          frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
          frame_resized = cv2.resize(frame_rgb, (width, height),
                                     interpolation=cv2.INTER_LINEAR)
          frame_queue.put(frame_resized)
          img_for_detect = darknet.make_image(width, height, 3)
          darknet.copy_image_from_bytes(img_for_detect, frame_resized.tobytes())
          darknet_image_queue.put(img_for_detect)
      cap.release()
  
  
  def inference(darknet_image_queue, detections_queue, fps_queue):
      while cap.isOpened():
          darknet_image = darknet_image_queue.get()
          prev_time = time.time()
          detections = darknet.detect_image(network, class_names, darknet_image, thresh=args.thresh)
          detections_queue.put(detections)
          fps = int(1/(time.time() - prev_time))
          fps_queue.put(fps)
          print(&quot;FPS: {}&quot;.format(fps))
          darknet.print_detections(detections, args.ext_output)
          darknet.free_image(darknet_image)
      cap.release()
  
  
  def drawing(frame_queue, detections_queue, fps_queue):
      random.seed(3)  # deterministic bbox colors
      video = set_saved_video(cap, args.out_filename, (width, height))
      while cap.isOpened():
          frame_resized = frame_queue.get()
          detections = detections_queue.get()
          fps = fps_queue.get()
          if frame_resized is not None:
              image = darknet.draw_boxes(detections, frame_resized, class_colors)
              image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
              if args.out_filename is not None:
                  video.write(image)
              if not args.dont_show:
                  cv2.imshow('Inference', image)
              if cv2.waitKey(fps) == 27:
                  break
      cap.release()
      video.release()
      cv2.destroyAllWindows()
  
  
  if __name__ == '__main__':
      frame_queue = Queue()
      darknet_image_queue = Queue(maxsize=1)
      detections_queue = Queue(maxsize=1)
      fps_queue = Queue(maxsize=1)
  
      args = parser()
      check_arguments_errors(args)
      network, class_names, class_colors = darknet.load_network(
              args.config_file,
              args.data_file,
              args.weights,
              batch_size=1
          )
      width = darknet.network_width(network)
      height = darknet.network_height(network)
      input_path = str2int(args.input)
      cap = cv2.VideoCapture(input_path)
      Thread(target=video_capture, args=(frame_queue, darknet_image_queue)).start()
      Thread(target=inference, args=(darknet_image_queue, detections_queue, fps_queue)).start()
      Thread(target=drawing, args=(frame_queue, detections_queue, fps_queue)).start()
  </code></pre>
  <p>Any ideas will be appreciated.</p>