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
if(ANDROID OR NOT UNIX)
install(FILES ${OPENCV_LICENSE_FILE}
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
DESTINATION ./ COMPONENT libs)
if(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)
endif()
endif()

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

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

@ -2,11 +2,19 @@
SETLOCAL
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
pause
exit
)
:: normalize path
for %%i in ("%PACKAGE_BUILD_DIR%") do SET "PACKAGE_BUILD_DIR=%%~fi"
:: Detect Python binary
python -V 2>nul
@ -80,7 +88,11 @@ echo SRC_FILENAME=%SRC_FILENAME%
call :dirname "%SRC_FILENAME%" SRC_DIR
call :dirname "%PYTHON%" PYTHON_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: %*
%PYTHON% %*
SET result=%errorlevel%
@ -94,17 +106,23 @@ IF %result% NEQ 0 (
cmd /k echo Current directory: %CD%
)
)
POPD
EXIT /B %result%
:rundemo
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
SET result=%errorlevel%
IF %result% NEQ 0 (
IF NOT DEFINED OPENCV_BATCH_MODE ( pause )
)
POPD
EXIT /B %result%

@ -114,12 +114,24 @@ class App:
def on_demo_select(self, evt):
name = self.demos_lb.get( self.demos_lb.curselection()[0] )
fn = self.samples[name]
loc = {}
descr = ""
try:
execfile(fn, loc) # Python 2
except NameError:
exec(open(fn).read(), loc) # Python 3
descr = loc.get('__doc__', 'no-description')
if sys.version_info[0] > 2:
# Python 3.x
module_globals = {}
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.text.config(state='normal')

Loading…
Cancel
Save