简体   繁体   English

OpenVINO 无法通过在 Windows 7 操作系统中执行 PowerShell 来安装 OpenCV

[英]OpenVINO cannot install OpenCV by executing with PowerShell in Windows 7 OS

I am trying to install openvino_2021.4.689 version with Windows 7 old computer.我正在尝试使用 Windows 7 旧计算机安装 openvino_2021.4.689 版本。

I need to use OpenCV with my project, so I have to use PowerShell to execute ffmpeg-download.psl in opencv folder of openvino_2021.4.689 like this .我需要在我的项目中使用 OpenCV,所以我必须使用 PowerShell 来执行 openvino_2021 的Z94756EA97E399882B121DA8BB2DE55E24.6文件夹中的ffmpeg-download.psl

If I install my own OpenCV by pip install opencv-python in Command Prompt rather than install by OpenVINO's ffmpeg-download.psl file, my project with cv2 library will not work successfully.如果我通过pip install opencv-python而不是通过 OpenVINO 的ffmpeg-download.psl文件安装,我的带有cv2库的项目将无法成功运行。

Specifically, my YOLOv4 frame will not show without any error message, what I use cv2 to draw images cannot work.具体来说,我的 YOLOv4 框架不会在没有任何错误消息的情况下显示,我使用cv2绘制图像无法正常工作。

But if I click ffmpeg-download.psl with right mouse button and select executed by PowerShell, I will get an error message as shown in the image .但是,如果我用鼠标右键单击ffmpeg-download.psl和 PowerShell 执行的 select,我将收到如图所示的错误消息。 (Executed with system administrator.) (由系统管理员执行。)

FATAL: Unable to write with elevated privileges: bin\opencv_videoio_ffmpeg45364.dll

Furthermore, this step always goes well in my Windows 10 or Windows 11 OS, it only happens in the Windows 7 outdated PC.此外,这一步在我的 Windows 10 或 Windows 11 操作系统中总是很顺利,它只发生在 Windows 7 过时的 PC 中。

And the following is what in the ffmpeg-download.psl .以下是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"

The validated and supported Operating System for Windows by Intel® Distribution of OpenVINO™ Toolkit is Windows 10, 64-bit.英特尔® Distribution of OpenVINO™ Toolkit 为 Windows 验证和支持的操作系统是 Windows 10,64 位。 Using older Windows version might contribute to unexpected issues.使用较旧的 Windows 版本可能会导致意外问题。

If only looking on your current encountered error, it might be due to Windows PowerShell compatibility version.如果仅查看您当前遇到的错误,则可能是由于 Windows PowerShell 兼容版本所致。 As it is mentioned in the ffmpeg-download.psl , which requires PowerShell 4+.正如ffmpeg-download.psl中提到的那样,它需要 PowerShell 4+。 While Windows 7 installed with the default version, Windows PowerShell 2.0. Windows 7 安装了默认版本,Windows PowerShell 2.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM