Merge pull request #16943 from alalek:winpack_samples_update_master

pull/16952/head
Alexander Alekhin 5 years ago committed by GitHub
commit d448a636f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CMakeLists.txt
  2. 3
      modules/videoio/CMakeLists.txt
  3. 45
      samples/_winpack_build_sample.cmd
  4. 24
      samples/_winpack_run_python_sample.cmd
  5. 22
      samples/python/demo.py

@ -946,11 +946,11 @@ endif()
# for UNIX it does not make sense as LICENSE and readme will be part of the package automatically # for UNIX it does not make sense as LICENSE and readme will be part of the package automatically
if(ANDROID OR NOT UNIX) if(ANDROID OR NOT UNIX)
install(FILES ${OPENCV_LICENSE_FILE} install(FILES ${OPENCV_LICENSE_FILE}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DESTINATION ./ COMPONENT libs) DESTINATION ./ COMPONENT libs)
if(OPENCV_README_FILE) if(OPENCV_README_FILE)
install(FILES ${OPENCV_README_FILE} install(FILES ${OPENCV_README_FILE}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DESTINATION ./ COMPONENT libs) DESTINATION ./ COMPONENT libs)
endif() endif()
endif() endif()

@ -221,7 +221,6 @@ if(WIN32 AND HAVE_FFMPEG_WRAPPER)
endif() endif()
install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}") install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}")
if(INSTALL_CREATE_DISTRIB) if(INSTALL_CREATE_DISTRIB)
install(FILES "${ffmpeg_dir}/opencv_videoio_ffmpeg.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_videoio_ffmpeg${OPENCV_DLLVERSION}.dll") install(FILES "${ffmpeg_dir}/opencv_videoio_ffmpeg${FFMPEG_SUFFIX}.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_videoio_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
install(FILES "${ffmpeg_dir}/opencv_videoio_ffmpeg_64.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_videoio_ffmpeg${OPENCV_DLLVERSION}_64.dll")
endif() endif()
endif() endif()

@ -4,16 +4,24 @@
:: - > _winpack_build_sample.cmd cpp\opencv_version.cpp :: - > _winpack_build_sample.cmd cpp\opencv_version.cpp
:: Requires: :: Requires:
:: - CMake :: - CMake
:: - MSVS 2015/2017 :: - MSVS 2015/2017/2019
:: (tools are searched on default paths or environment should be pre-configured) :: (tools are searched on default paths or environment should be pre-configured)
@echo off @echo off
setlocal setlocal
set SCRIPTDIR=%~dp0 SET SCRIPT_DIR=%~dp0
if NOT exist "%SCRIPTDIR%\..\..\build" ( SET "OPENCV_SETUPVARS_SCRIPT=setup_vars_opencv4.cmd"
SET "PACKAGE_BUILD_DIR=%SCRIPT_DIR%\..\..\build"
IF NOT EXIST "%PACKAGE_BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%" (
:: Winpack DLDT
SET "PACKAGE_BUILD_DIR=%SCRIPT_DIR%\..\..\..\build"
)
IF NOT EXIST "%PACKAGE_BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%" (
set "MSG=OpenCV Winpack installation is required" set "MSG=OpenCV Winpack installation is required"
goto die goto die
) )
:: normalize path
for %%i in ("%PACKAGE_BUILD_DIR%") do SET "PACKAGE_BUILD_DIR=%%~fi"
if [%1]==[] ( if [%1]==[] (
set "MSG=Sample path is required" set "MSG=Sample path is required"
@ -35,8 +43,8 @@ set "SRC_NAME=%~n1"
echo SRC_NAME=%SRC_NAME% echo SRC_NAME=%SRC_NAME%
echo ================================================================================ echo ================================================================================
:: Path to FFMPEG binary files :: Path to root 'bin' dir
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\bin\" set "PATH=%PACKAGE_BUILD_DIR%\bin;%PATH%"
:: Detect compiler :: Detect compiler
cl /? >NUL 2>NUL <NUL cl /? >NUL 2>NUL <NUL
@ -102,12 +110,21 @@ if NOT DEFINED VisualStudioVersion (
if "%VisualStudioVersion%" == "14.0" ( if "%VisualStudioVersion%" == "14.0" (
set "CMAKE_GENERATOR=-G^"Visual Studio 14 Win64^"" set "CMAKE_GENERATOR=-G^"Visual Studio 14 Win64^""
set "BUILD_DIR_SUFFIX=.vc14" set "BUILD_DIR_SUFFIX=.vc14"
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc14\bin\" if EXIST "%PACKAGE_BUILD_DIR%\x64\vc14\bin" (
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc14\bin;%PATH%"
)
) else ( ) else (
if "%VisualStudioVersion%" == "15.0" ( if "%VisualStudioVersion%" == "15.0" (
set "CMAKE_GENERATOR=-G^"Visual Studio 15 Win64^"" set "CMAKE_GENERATOR=-G^"Visual Studio 15 Win64^""
set "BUILD_DIR_SUFFIX=.vc15" set "BUILD_DIR_SUFFIX=.vc15"
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc15\bin\" set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc15\bin\"
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc15\bin" (
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc15\bin;%PATH%"
) else (
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc14\bin" (
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc14\bin;%PATH%"
)
)
) else ( ) else (
if "%VisualStudioVersion%" == "16.0" ( if "%VisualStudioVersion%" == "16.0" (
echo.========================================== echo.==========================================
@ -115,7 +132,17 @@ if "%VisualStudioVersion%" == "14.0" (
echo.========================================== echo.==========================================
set "CMAKE_GENERATOR=-G^"Visual Studio 16 2019^" -A x64" set "CMAKE_GENERATOR=-G^"Visual Studio 16 2019^" -A x64"
set "BUILD_DIR_SUFFIX=.vc16" set "BUILD_DIR_SUFFIX=.vc16"
set "PATH=%PATH%;%SCRIPTDIR%\..\..\build\x64\vc15\bin\" if EXIST "%PACKAGE_BUILD_DIR%\x64\vc16\bin" (
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc16\bin;%PATH%"
) else (
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc15\bin" (
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc15\bin;%PATH%"
) else (
if EXIST "%PACKAGE_BUILD_DIR%\x64\vc14\bin" (
set "PATH=%PACKAGE_BUILD_DIR%\x64\vc14\bin;%PATH%"
)
)
)
) else ( ) else (
set "MSG=Unsupported MSVS version. VisualStudioVersion=%VisualStudioVersion%" set "MSG=Unsupported MSVS version. VisualStudioVersion=%VisualStudioVersion%"
goto die goto die
@ -128,10 +155,10 @@ call :set_title Create build directory
if NOT exist "%BUILD_DIR%" ( call :execute md "%BUILD_DIR%" ) if NOT exist "%BUILD_DIR%" ( call :execute md "%BUILD_DIR%" )
PUSHD "%BUILD_DIR%" PUSHD "%BUILD_DIR%"
if NOT exist "%BUILD_DIR%/sample" ( call :execute md "%BUILD_DIR%/sample" ) if NOT exist "%BUILD_DIR%/sample" ( call :execute md "%BUILD_DIR%/sample" )
call :execute copy /Y "%SCRIPTDIR%/CMakeLists.example.in" "%BUILD_DIR%/sample/CMakeLists.txt" call :execute copy /Y "%SCRIPT_DIR%/CMakeLists.example.in" "%BUILD_DIR%/sample/CMakeLists.txt"
call :set_title Configuring via CMake call :set_title Configuring via CMake
call :execute cmake %CMAKE_GENERATOR% "%BUILD_DIR%\sample" -DEXAMPLE_NAME=%SRC_NAME% "-DEXAMPLE_FILE=%SRC_FILENAME%" "-DOpenCV_DIR=%SCRIPTDIR%\..\..\build" call :execute cmake %CMAKE_GENERATOR% "%BUILD_DIR%\sample" -DEXAMPLE_NAME=%SRC_NAME% "-DEXAMPLE_FILE=%SRC_FILENAME%"
if %ERRORLEVEL% NEQ 0 ( if %ERRORLEVEL% NEQ 0 (
set "MSG=CMake configuration step failed: %BUILD_DIR%" set "MSG=CMake configuration step failed: %BUILD_DIR%"
goto die goto die

@ -2,11 +2,19 @@
SETLOCAL SETLOCAL
SET SCRIPT_DIR=%~dp0 SET SCRIPT_DIR=%~dp0
IF NOT EXIST "%SCRIPT_DIR%\..\..\build\setup_vars_opencv4.cmd" ( SET "OPENCV_SETUPVARS_SCRIPT=setup_vars_opencv4.cmd"
SET "BUILD_DIR=%SCRIPT_DIR%\..\..\build"
IF NOT EXIST "%BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%" (
:: Winpack DLDT
SET "BUILD_DIR=%SCRIPT_DIR%\..\..\..\build"
)
IF NOT EXIST "%BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%" (
ECHO ERROR: OpenCV Winpack installation is required ECHO ERROR: OpenCV Winpack installation is required
pause pause
exit exit
) )
:: normalize path
for %%i in ("%PACKAGE_BUILD_DIR%") do SET "PACKAGE_BUILD_DIR=%%~fi"
:: Detect Python binary :: Detect Python binary
python -V 2>nul python -V 2>nul
@ -80,7 +88,11 @@ echo SRC_FILENAME=%SRC_FILENAME%
call :dirname "%SRC_FILENAME%" SRC_DIR call :dirname "%SRC_FILENAME%" SRC_DIR
call :dirname "%PYTHON%" PYTHON_DIR call :dirname "%PYTHON%" PYTHON_DIR
PUSHD %SRC_DIR% PUSHD %SRC_DIR%
CALL "%SCRIPT_DIR%\..\..\build\setup_vars_opencv4.cmd"
CALL "%BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%"
:: repair SCRIPT_DIR
SET "SCRIPT_DIR=%~dp0"
ECHO Run: %* ECHO Run: %*
%PYTHON% %* %PYTHON% %*
SET result=%errorlevel% SET result=%errorlevel%
@ -94,17 +106,23 @@ IF %result% NEQ 0 (
cmd /k echo Current directory: %CD% cmd /k echo Current directory: %CD%
) )
) )
POPD POPD
EXIT /B %result% EXIT /B %result%
:rundemo :rundemo
PUSHD "%SCRIPT_DIR%\python" PUSHD "%SCRIPT_DIR%\python"
CALL "%SCRIPT_DIR%\..\..\build\setup_vars_opencv4.cmd"
CALL "%BUILD_DIR%\%OPENCV_SETUPVARS_SCRIPT%"
:: repair SCRIPT_DIR
SET "SCRIPT_DIR=%~dp0"
%PYTHON% demo.py %PYTHON% demo.py
SET result=%errorlevel% SET result=%errorlevel%
IF %result% NEQ 0 ( IF %result% NEQ 0 (
IF NOT DEFINED OPENCV_BATCH_MODE ( pause ) IF NOT DEFINED OPENCV_BATCH_MODE ( pause )
) )
POPD POPD
EXIT /B %result% EXIT /B %result%

@ -114,12 +114,24 @@ class App:
def on_demo_select(self, evt): def on_demo_select(self, evt):
name = self.demos_lb.get( self.demos_lb.curselection()[0] ) name = self.demos_lb.get( self.demos_lb.curselection()[0] )
fn = self.samples[name] fn = self.samples[name]
loc = {}
descr = ""
try: try:
execfile(fn, loc) # Python 2 if sys.version_info[0] > 2:
except NameError: # Python 3.x
exec(open(fn).read(), loc) # Python 3 module_globals = {}
descr = loc.get('__doc__', 'no-description') module_locals = {}
with open(fn, 'r') as f:
module_code = f.read()
exec(compile(module_code, fn, 'exec'), module_globals, module_locals)
descr = module_locals.get('__doc__', 'no-description')
else:
# Python 2
module_globals = {}
execfile(fn, module_globals) # noqa: F821
descr = module_globals.get('__doc__', 'no-description')
except Exception as e:
descr = str(e)
self.linker.reset() self.linker.reset()
self.text.config(state='normal') self.text.config(state='normal')

Loading…
Cancel
Save