如何编码以修复检测到的致命错误:在使用auto-py-to-exe将python代码编译为exe文件后,无法执行脚本BoxDetection?

如何编码以修复检测到的致命错误:使用自动py-to-exe编译python代码到exe文件后,无法执行脚本BoxDetection?

我学会了使用vdo链接https://www.youtube.com/watch?v=ZtBTrARHJps&list=WL&index=3&t=156s将python代码编译为exe文件

我在使用自动py-to-exe编译python代码到exe文件后遇到问题,并且在程序完成工作后出现了弹出错误

Fatal error detected
Failed to execute script BoxDetection

图片链接出现弹出错误-https://i.imgur.com/ycQrFJ4.jpg询问如何编码以将弹出错误修复为无法执行脚本BoxDetection 问题。

示例代码

  1. BoxDetection.py
import cv2
import numpy as np

from tkinter import Tk
from tkinter.filedialog import askopenfilename

Tk().withdraw() # we don't want a full GUI,so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog Box and return the path to the selected file
cap=cv2.VideoCapture(filename) # Compatible with Box2 mp4 video file

while(cap.read()) :
     ref,frame = cap.read()
     roi=frame[:1080,0:1920]

     gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
     gray_blur=cv2.GaussianBlur(gray,(25,25),0)
     thresh=cv2.adaptiveThreshold(gray_blur,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY_INV,21,4)
     kernel=np.ones((3,3),np.uint8)
     closing=cv2.morphologyEx(thresh,cv2.MORPH_CLOSE,kernel,iterations=4)

     result_img=closing.copy()
     contours,hierachy=cv2.findContours(result_img,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
     counter=0
     for cnt in contours:
         area = cv2.contourArea(cnt)
         if area<622 :
             continue
         # ellipse = cv2.fitEllipse(cnt)
         # cv2.ellipse(roi,ellipse,(0,0),2)
         counter+=1

     cv2.putText(roi,str(counter),(10,100),cv2.FONT_HERShey_SIMPLEX,4,255),cv2.LINE_AA)
     cv2.imshow("Show",roi)

     if cv2.waitKey(1) & 0xFF==ord('q'):
         break

cap.release()
cv2.destroyAllWindows()
  1. Boxdetectionerrorlog.txt和下载链接

https://doanga2007.github.io/boxdetectionerrorlog.txt

  1. 带有链接-https://doanga2007.github.io/box2.mp4

    的VDO示例Box2.mp4
  2. BoxDetection.exe 64位使用自动py-to-exe编译python代码到具有下载链接的exe文件

https://drive.google.com/file/d/1tnnnDWRrg1NbPZ3hr9mhY-t_4zry21rB/view?usp=sharing

如果打开BoxDetection.exe并选择示例VDO Box2.mp4,则在程序完成图片链接处理后出现弹出错误

https://i.imgur.com/p06GzjP.jpg

  1. Boxdetectionerrorlog+debug.txt和下载链接

https://doanga2007.github.io/boxdetectionerrorlog+debug.txt

  1. 用于描述运行模块后的错误日志的Python Shell。
Python 3.8.5 (tags/v3.8.5:580fbb0,Jul 20 2020,15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help","copyright","credits" or "license()" for more @R_38_4045@ion.
>>> 
== RESTART: C:\Users\tum\Desktop\โปรแกรม BoxDetection แบบ EXE\BoxDetection.py ==
Traceback (most recent call last):
  File "C:\Users\tum\Desktop\โปรแกรม BoxDetection แบบ EXE\BoxDetection.py",line 13,in <module>
    roi=frame[:1080,0:1920]
TypeError: 'nonetype' object is not subscriptable
>>>

相关文章

功能概要:(目前已实现功能)公共展示部分:1.网站首页展示...
大体上把Python中的数据类型分为如下几类: Number(数字) ...
开发之前第一步,就是构造整个的项目结构。这就好比作一幅画...
源码编译方式安装Apache首先下载Apache源码压缩包,地址为ht...
前面说完了此项目的创建及数据模型设计的过程。如果未看过,...
python中常用的写爬虫的库有urllib2、requests,对于大多数比...