【问题标题】:OSError: [WinError 740] The requested operation requires elevation pytesseractOSError: [WinError 740] 请求的操作需要提升 pytesseract
【发布时间】:2021-09-05 16:21:28
【问题描述】:
import cv2
import imutils
import numpy as np
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Users\DELL\Downloads\Helmet and Number Plate\Helmet and Number Plate\tesseract-ocr-setup-3.02.02.exe'

img = cv2.imread('main1.png',cv2.IMREAD_COLOR)
img = cv2.resize(img, (600,400) )

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 
gray = cv2.bilateralFilter(gray, 13, 15, 15) 

edged = cv2.Canny(gray, 30, 200) 
contours = cv2.findContours(edged.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contours = imutils.grab_contours(contours)
contours = sorted(contours, key = cv2.contourArea, reverse = True)[:10]
screenCnt = None

for c in contours:
    
    peri = cv2.arcLength(c, True)
    approx = cv2.approxPolyDP(c, 0.018 * peri, True)
 
    if len(approx) == 4:
        screenCnt = approx
        break

if screenCnt is None:
    detected = 0
    print ("No contour detected")
else:
     detected = 1

if detected == 1:
    cv2.drawContours(img, [screenCnt], -1, (0, 0, 255), 3)

mask = np.zeros(gray.shape,np.uint8)
new_image = cv2.drawContours(mask,[screenCnt],0,255,-1,)
new_image = cv2.bitwise_and(img,img,mask=mask)

(x, y) = np.where(mask == 255)
(topx, topy) = (np.min(x), np.min(y))
(bottomx, bottomy) = (np.max(x), np.max(y))
Cropped = gray[topx:bottomx+1, topy:bottomy+1]

text = pytesseract.image_to_string(Cropped, config='--psm 11')
print("programming_fever's License Plate Recognition\n")
print("Detected license plate Number is:",text)
img = cv2.resize(img,(500,300))
Cropped = cv2.resize(Cropped,(400,200))
cv2.imshow('car',img)
cv2.imshow('Cropped',Cropped)

cv2.waitKey(0)
cv2.destroyAllWindows()
Traceback (most recent call last):
  File "C:/Users/DELL/Downloads/Helmet and Number Plate/Helmet and Number Plate/char_ex.py", line 46, in <module>
    text = pytesseract.image_to_string(Cropped, config='--psm 11')
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\pytesseract\pytesseract.py", line 413, in image_to_string
    }[output_type]()
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\pytesseract\pytesseract.py", line 412, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\pytesseract\pytesseract.py", line 287, in run_and_get_output
    run_tesseract(**kwargs)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\pytesseract\pytesseract.py", line 258, in run_tesseract
    raise e
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\pytesseract\pytesseract.py", line 255, in run_tesseract
    proc = subprocess.Popen(cmd_args, **subprocess_args())
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 990, in _execute_child
    startupinfo)
OSError: [WinError 740] The requested operation requires elevation

【问题讨论】:

  • 这意味着您需要管理权限
  • 我以管理员身份运行它

标签: python computer-vision


【解决方案1】:

我认为您必须以管理员身份运行终端或 IDE

【讨论】:

  • 应用程序的终端或调用者应以管理员身份运行或具有超级用户权限。您是否尝试过在超级管理员中运行终端并运行应用程序?
猜你喜欢
  • 2020-09-26
  • 1970-01-01
  • 2011-10-30
  • 1970-01-01
  • 2014-10-25
  • 2013-02-08
  • 2021-11-17
  • 1970-01-01
  • 2011-05-10
相关资源
最近更新 更多