OpenVINO 无法通过在 Windows 7 OS 中使用 PowerShell 执行来安装 OpenCV
OpenVINO cannot install OpenCV by executing with PowerShell in Windows 7 OS
我正在尝试用 Windows 7 台旧电脑安装 openvino_2021.4.689 版本。
我的项目需要使用OpenCV,所以我必须使用PowerShell在openvino_2021.4.689的opencv文件夹中执行ffmpeg-download.psl like this.
如果我在命令提示符下通过 pip install opencv-python
安装我自己的 OpenCV 而不是通过 OpenVINO 的 ffmpeg-download.psl 文件安装,我的项目 cv2
库将无法成功运行。
具体来说,我的YOLOv4框架没有任何错误信息就无法显示,我使用cv2
绘制图像的方法无法工作。
但是如果我用鼠标右键单击 ffmpeg-download.psl 并由 PowerShell 执行 select,我将收到一条错误消息,如image。 (与系统管理员一起执行。)
FATAL: Unable to write with elevated privileges: bin\opencv_videoio_ffmpeg45364.dll
此外,这一步在我的Windows10或Windows11OS中总是很顺利,它只发生在Windows7过时的PC上。
下面是ffmpeg-download.psl.
中的内容
$url = "https://raw.githubusercontent.com/opencv/opencv_3rdparty/213fcd5d4897319a83207406036c4a5957fba010/ffmpeg/opencv_videoio_ffmpeg_64.dll"
$expected_md5 = "ac99f9767a83103c31709628af685924"
$output = "$PSScriptRoot\bin\opencv_videoio_ffmpeg453_64.dll"
Write-Output ("=" * 120)
try {
Get-content -Path "$PSScriptRoot\etc/licenses\ffmpeg-readme.txt" -ErrorAction 'Stop'
} catch {
Write-Output "Refer to OpenCV FFmpeg wrapper readme notes about library usage / licensing details."
}
Write-Output ("=" * 120)
Write-Output ""
if(![System.IO.File]::Exists($output)) {
try {
[io.file]::OpenWrite($output).close()
} catch {
Write-Warning "Unable to write: $output"
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Launching with 'Administrator' elevated privileges..."
Pause
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
} else {
Write-Output "FATAL: Unable to write with elevated privileges: $output"
Pause
exit 1
}
}
try {
Write-Output ("Downloading: " + $output)
Import-Module BitsTransfer
$start_time = Get-Date
Start-BitsTransfer -Source $url -Destination $output -ErrorAction 'Stop'
Write-Output "Downloaded in $((Get-Date).Subtract($start_time).Seconds) seconds"
} catch {
$_ # Dump error
try {
Write-Output ("Downloading (second attempt): " + $output)
$start_time = Get-Date
Invoke-WebRequest -Uri $url -OutFile $output
Write-Output "Downloaded in $((Get-Date).Subtract($start_time).Seconds) seconds"
} catch {
Write-Output ("Can't download file: " + $output)
Write-Output ("URL: " + $url)
Write-Output "You need to download this file manually. Stop"
Pause
Exit
}
}
} else {
Write-Output ("File exists: " + $output)
Write-Output ("Downloading is skipped. Remove this file and re-run this script to force downloading.")
}
if(![System.IO.File]::Exists($output)) {
Write-Output ("Destination file not found: " + $output)
Write-Output "Stop"
Pause
Exit
}
try {
$hash = Get-FileHash $output -Algorithm MD5 -ErrorAction 'Stop'
if($hash.Hash -eq $expected_md5) {
Write-Output "MD5 check passed"
} else {
Write-Output ("MD5 : " + $hash.Hash.toLower())
Write-Output ("Expected: " + $expected_md5)
Write-Output "MD5 hash mismatch"
}
} catch {
$_ # Dump error
Write-Output "Can't check MD5 hash (requires PowerShell 4+)"
}
Pause
Write-Output "Exit"
英特尔® Distribution of OpenVINO™ Toolkit 为 Windows 验证和支持的操作系统是 Windows 10,64 位。使用旧 Windows 版本可能会导致意外问题。
如果仅查看您当前遇到的错误,可能是由于 Windows PowerShell 兼容版本。正如 ffmpeg-download.psl 中提到的那样,它需要 PowerShell 4+。 Windows 7 使用默认版本安装,Windows PowerShell 2.0.
我正在尝试用 Windows 7 台旧电脑安装 openvino_2021.4.689 版本。
我的项目需要使用OpenCV,所以我必须使用PowerShell在openvino_2021.4.689的opencv文件夹中执行ffmpeg-download.psl like this.
如果我在命令提示符下通过 pip install opencv-python
安装我自己的 OpenCV 而不是通过 OpenVINO 的 ffmpeg-download.psl 文件安装,我的项目 cv2
库将无法成功运行。
具体来说,我的YOLOv4框架没有任何错误信息就无法显示,我使用cv2
绘制图像的方法无法工作。
但是如果我用鼠标右键单击 ffmpeg-download.psl 并由 PowerShell 执行 select,我将收到一条错误消息,如image。 (与系统管理员一起执行。)
FATAL: Unable to write with elevated privileges: bin\opencv_videoio_ffmpeg45364.dll
此外,这一步在我的Windows10或Windows11OS中总是很顺利,它只发生在Windows7过时的PC上。
下面是ffmpeg-download.psl.
中的内容$url = "https://raw.githubusercontent.com/opencv/opencv_3rdparty/213fcd5d4897319a83207406036c4a5957fba010/ffmpeg/opencv_videoio_ffmpeg_64.dll"
$expected_md5 = "ac99f9767a83103c31709628af685924"
$output = "$PSScriptRoot\bin\opencv_videoio_ffmpeg453_64.dll"
Write-Output ("=" * 120)
try {
Get-content -Path "$PSScriptRoot\etc/licenses\ffmpeg-readme.txt" -ErrorAction 'Stop'
} catch {
Write-Output "Refer to OpenCV FFmpeg wrapper readme notes about library usage / licensing details."
}
Write-Output ("=" * 120)
Write-Output ""
if(![System.IO.File]::Exists($output)) {
try {
[io.file]::OpenWrite($output).close()
} catch {
Write-Warning "Unable to write: $output"
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Launching with 'Administrator' elevated privileges..."
Pause
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
exit
} else {
Write-Output "FATAL: Unable to write with elevated privileges: $output"
Pause
exit 1
}
}
try {
Write-Output ("Downloading: " + $output)
Import-Module BitsTransfer
$start_time = Get-Date
Start-BitsTransfer -Source $url -Destination $output -ErrorAction 'Stop'
Write-Output "Downloaded in $((Get-Date).Subtract($start_time).Seconds) seconds"
} catch {
$_ # Dump error
try {
Write-Output ("Downloading (second attempt): " + $output)
$start_time = Get-Date
Invoke-WebRequest -Uri $url -OutFile $output
Write-Output "Downloaded in $((Get-Date).Subtract($start_time).Seconds) seconds"
} catch {
Write-Output ("Can't download file: " + $output)
Write-Output ("URL: " + $url)
Write-Output "You need to download this file manually. Stop"
Pause
Exit
}
}
} else {
Write-Output ("File exists: " + $output)
Write-Output ("Downloading is skipped. Remove this file and re-run this script to force downloading.")
}
if(![System.IO.File]::Exists($output)) {
Write-Output ("Destination file not found: " + $output)
Write-Output "Stop"
Pause
Exit
}
try {
$hash = Get-FileHash $output -Algorithm MD5 -ErrorAction 'Stop'
if($hash.Hash -eq $expected_md5) {
Write-Output "MD5 check passed"
} else {
Write-Output ("MD5 : " + $hash.Hash.toLower())
Write-Output ("Expected: " + $expected_md5)
Write-Output "MD5 hash mismatch"
}
} catch {
$_ # Dump error
Write-Output "Can't check MD5 hash (requires PowerShell 4+)"
}
Pause
Write-Output "Exit"
英特尔® Distribution of OpenVINO™ Toolkit 为 Windows 验证和支持的操作系统是 Windows 10,64 位。使用旧 Windows 版本可能会导致意外问题。
如果仅查看您当前遇到的错误,可能是由于 Windows PowerShell 兼容版本。正如 ffmpeg-download.psl 中提到的那样,它需要 PowerShell 4+。 Windows 7 使用默认版本安装,Windows PowerShell 2.0.