title: How to view the calibrated real-time video in the .exe?
body: <p>I have a question for calibration of real-time video during the project.</p>
  <p>Development Environment:
  python 3.8 64bit
  window
  visual studio code</p>
  <p>While showing real-time video on the screen through opencv, I realized that calibration was needed on the camera screen. So, calibration was successful through many searches. When I run it in 'vusual studio code' it works fine. But after creating the .exe via pyinstaller, the camera does not open. No error occurs. So I don't know any more. Any help would be greatly appreciated.</p>
  <p>Saved 'mtx, dist, rvecs, tvecs' as 'calibration.npz' in the same path as the code. After that, I loaded it through the code below.</p>
  <pre><code>h,w = frame.shape[:2]  
  with np.load('calibration.npz') as X:
      mtx, dist, _ , _ = [X[i] for i in ('mtx','dist','rvecs','tvecs')]
  newcameramtx, roi = cv2.getOptimalNewCameraMatrix(mtx, dist, (w, h), 0)
  mapx, mapy = cv2.initUndistortRectifyMap(mtx, dist, None, newcameramtx,(w, h), 5)
  
              
  dst = cv2.remap(frame, mapx, mapy, cv2.INTER_LINEAR)
  global dst_final       
  x, y, w, h = roi
  dst_final=dst[y:y+h, x:x+w]
  
  </code></pre>
  <p>'calibration.npz' save code is:</p>
  <pre><code>#!/usr/bin/env python
  
  import cv2
  import numpy as np
  import os
  import glob
  
  CHECKERBOARD = (6,9)
  criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
  
  objpoints = []
  imgpoints = [] 
  
  
  objp = np.zeros((1, CHECKERBOARD[0] * CHECKERBOARD[1], 3), np.float32)
  objp[0,:,:2] = np.mgrid[0:CHECKERBOARD[0], 0:CHECKERBOARD[1]].T.reshape(-1, 2)*26  #*26 = 26mm(chekerboard size(mm))
  prev_img_shape = None
  
  images = glob.glob('C:\\Users\\MyPc\\KHS\\test2\\*.jpg')
  for fname in images:
      img = cv2.imread(fname)
      gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
      ret, corners = cv2.findChessboardCorners(gray, CHECKERBOARD, cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_FAST_CHECK + cv2.CALIB_CB_NORMALIZE_IMAGE)
      
      if ret == True:
          objpoints.append(objp)
          corners2 = cv2.cornerSubPix(gray, corners, (11,11),(-1,-1), criteria)
          
          imgpoints.append(corners2)
  
          img = cv2.drawChessboardCorners(img, CHECKERBOARD, corners2, ret)
      
      cv2.imshow('img',img)
      cv2.waitKey(0)
  
  cv2.destroyAllWindows()
  
  h,w = img.shape[:2]
  
  
  ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1], None, None)
  newcameramtx, roi = cv2.getOptimalNewCameraMatrix(mtx, dist, (w, h), 0)
  mapx, mapy = cv2.initUndistortRectifyMap(mtx, dist, None, newcameramtx,(w, h), 5)
  dst = cv2.remap(img, mapx, mapy, cv2.INTER_LINEAR)
      
  x, y, w, h = roi
  dst=dst[y:y+h, x:x+w]
  cv2.imshow('num', dst)
  cv2.imshow('ori', img)
  cv2.waitKey(0)
  
  np.savez_compressed('calibration.npz',ret=ret,mtx=mtx,dist=dist,rvecs=rvecs,tvecs=tvecs)
  </code></pre>
  <p>When creating the .exe, I ran the following code:</p>
  <pre><code>pyinstaller -w --ico=myico.ico --add-data *.png;. ABC.py
  </code></pre>
  <p>In the .exe before calibration, the real-time video appeared on the screen, but in the .exe created after calibration, the real-time video does not appear on the screen and there are no other errors.</p>
  <p>Any advice would be much appreciated. Please advise.</p>