├── .github └── workflows │ ├── SyncFromSourceforge.yml │ └── SyncToGitee.yml ├── .gitignore ├── CMakeLists.txt ├── Components ├── CUDAKernels │ ├── CMakeLists.txt │ ├── CUDAKernels.vcxproj │ ├── CUDAKernels.vcxproj.user │ ├── cuda_kernels.cu │ ├── cuda_kernels.h │ └── kmeans │ │ ├── LICENSE │ │ ├── cuda_kmeans.cu │ │ └── kmeans.h ├── FFMPEGVideo │ ├── CMakeLists.txt │ ├── FFMPEGVideo.cpp │ ├── FFMPEGVideo.h │ ├── FFMPEGVideo.vcxproj │ ├── FFMPEGVideo.vcxproj.filters │ ├── FFMPEGVideoLoader.cpp │ └── FFMPEGVideoLoader.h ├── IPAlgorithms │ ├── CMakeLists.txt │ ├── IPAlgorithms.cpp │ ├── IPAlgorithms.h │ ├── IPAlgorithms.vcxproj │ ├── IPAlgorithms.vcxproj.filters │ ├── MyClosedFigure.cpp │ ├── MyClosedFigure.h │ ├── SSAlgorithms.cpp │ └── SSAlgorithms.h ├── Include │ ├── DataTypes.h │ └── Video.h └── OCVVideo │ ├── CMakeLists.txt │ ├── OCVVideo.cpp │ ├── OCVVideo.h │ ├── OCVVideo.vcxproj │ ├── OCVVideo.vcxproj.filters │ ├── OCVVideoLoader.cpp │ └── OCVVideoLoader.h ├── Data └── bitmaps │ ├── left_na.bmp │ ├── left_od.bmp │ ├── right_na.bmp │ ├── right_od.bmp │ ├── sb_la.bmp │ ├── sb_lc.bmp │ ├── sb_ra.bmp │ ├── sb_rc.bmp │ ├── sb_t.bmp │ ├── tb_pause.bmp │ ├── tb_run.bmp │ └── tb_stop.bmp ├── Docs ├── build.txt ├── readme_chn.txt ├── readme_eng.txt └── readme_rus.txt ├── Interfaces └── VideoSubFinderWXW │ ├── BitmapButton.cpp │ ├── BitmapButton.h │ ├── Button.cpp │ ├── Button.h │ ├── CMakeLists.txt │ ├── CheckBox.cpp │ ├── CheckBox.h │ ├── Choice.cpp │ ├── Choice.h │ ├── CommonFunctions.cpp │ ├── CommonFunctions.h │ ├── Control.h │ ├── DataGrid.cpp │ ├── DataGrid.h │ ├── ImageBox.cpp │ ├── ImageBox.h │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── MyResource.h │ ├── OCRPanel.cpp │ ├── OCRPanel.h │ ├── ResizableWindow.cpp │ ├── ResizableWindow.h │ ├── SSOWnd.cpp │ ├── SSOWnd.h │ ├── ScrollBar.cpp │ ├── ScrollBar.h │ ├── SearchPanel.cpp │ ├── SearchPanel.h │ ├── SeparatingLine.cpp │ ├── SeparatingLine.h │ ├── SettingsPanel.cpp │ ├── SettingsPanel.h │ ├── StaticBox.cpp │ ├── StaticBox.h │ ├── StaticText.cpp │ ├── StaticText.h │ ├── TextCtrl.cpp │ ├── TextCtrl.h │ ├── VideoBox.cpp │ ├── VideoBox.h │ ├── VideoSubFinderWXW.cpp │ ├── VideoSubFinderWXW.h │ ├── VideoSubFinderWXW.rc │ ├── VideoSubFinderWXW.sln │ ├── VideoSubFinderWXW.vcxproj │ ├── VideoSubFinderWXW.vcxproj.filters │ ├── VideoSubFinderWXW.vcxproj.user │ ├── resource.h │ └── videosubfinder.ico ├── LICENSE ├── README.md └── Settings ├── Localization ├── chn │ └── locale.cfg ├── eng │ └── locale.cfg └── rus │ └── locale.cfg └── general.cfg /.github/workflows/SyncFromSourceforge.yml: -------------------------------------------------------------------------------- 1 | name: Sync From Sourceforge 2 | on: 3 | push: 4 | branches: 5 | - '**' 6 | schedule: 7 | - cron: '0 0 1 * *' # 8点运行 8 | 9 | env: 10 | REPO_SSH: git@github.com:SWHL/VideoSubFinder.git 11 | CLONE_URL: ${{ github.event.repository.clone_url }} 12 | USER_NAME: ${{ github.event.repository.owner.name }} 13 | USER_EMAIL: ${{ github.event.repository.owner.email }} 14 | SUBMMIT_BRANCH: main 15 | 16 | jobs: 17 | repo-sync: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Set SSH Environment 21 | env: 22 | DEPLOY_KEYS: ${{ secrets.DEPLOY_KEYS }} 23 | run: | 24 | mkdir -p ~/.ssh/ 25 | echo "$DEPLOY_KEYS" > ~/.ssh/id_rsa 26 | chmod 600 ~/.ssh/id_rsa 27 | chmod 700 ~/.ssh && chmod 600 ~/.ssh/* 28 | git config --global user.name $USER_NAME 29 | git config --global user.email $USER_EMAIL 30 | 31 | - name: Sync from sourceforge 32 | run: | 33 | git clone $REPO_SSH 34 | cd VideoSubFinder 35 | git remote add upstream https://git.code.sf.net/p/videosubfinder/src 36 | git fetch upstream master 37 | git checkout -b local_upstream upstream/master 38 | git pull upstream master 39 | git status 40 | git rebase main 41 | git checkout main 42 | 43 | git merge local_upstream 44 | git status 45 | git push 46 | 47 | -------------------------------------------------------------------------------- /.github/workflows/SyncToGitee.yml: -------------------------------------------------------------------------------- 1 | name: syncToGitee 2 | on: 3 | push: 4 | branches: 5 | - '**' 6 | jobs: 7 | repo-sync: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout source codes 11 | uses: actions/checkout@v2 12 | 13 | - name: Mirror the Github organization repos to Gitee. 14 | uses: Yikun/hub-mirror-action@master 15 | with: 16 | src: 'github/SWHL' 17 | dst: 'gitee/SWHL' 18 | dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} 19 | dst_token: ${{ secrets.GITEE_TOKEN }} 20 | force_update: true 21 | # only sync this repo 22 | static_list: "VideoSubFinder" 23 | debug: true 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore Everything 2 | * 3 | 4 | # But not: 5 | !*.cpp 6 | !*.c 7 | !*.hpp 8 | !*.h 9 | !*.cu 10 | !.gitignore 11 | # Or directories 12 | !*/ 13 | 14 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(VideoSubFinderWXW LANGUAGES CXX) 4 | 5 | if(WIN32) 6 | option(WIN64 "Make x64 build" ON) 7 | 8 | if(WIN64) 9 | find_package(IntelDPCPP REQUIRED) 10 | option(USE_CUDA "Build with CUDA support" ON) 11 | add_definitions(-DWIN64) 12 | set(wxWidgets_INCLUDE_DIRS "$ENV{WX_WIDGETS_PATH}/lib/vc_x64_lib/mswu;$ENV{WX_WIDGETS_PATH}/include" CACHE STRING "Paths to OpenCV include dirs") 13 | set(OpenCV_INCLUDE_DIRS "$ENV{OPENCV_BUILD_PATH_X64}/install/include" CACHE STRING "Paths to OpenCV include dirs") 14 | set(FFMPEG_INCLUDE_DIRS "$ENV{FFMPEG_PATH_X64}/include" CACHE STRING "Paths to FFMPEG include dirs") 15 | set(VideoSubFinderWXW_LINK_DIRS "$ENV{WX_WIDGETS_PATH}/lib/vc_x64_lib;$ENV{OPENCV_BUILD_PATH_X64}/lib/Release;$ENV{CUDA_TOOLKIT_PATH}/lib/x64;$ENV{FFMPEG_PATH_X64}/lib" CACHE STRING "VideoSubFinderWXW link dirs") 16 | else() 17 | option(USE_CUDA "Build with CUDA support" OFF) 18 | add_definitions(-DWINX86) 19 | set(wxWidgets_INCLUDE_DIRS "$ENV{WX_WIDGETS_PATH}/lib/vc_lib/mswu;$ENV{WX_WIDGETS_PATH}/include" CACHE STRING "Paths to OpenCV include dirs") 20 | set(OpenCV_INCLUDE_DIRS "$ENV{OPENCV_BUILD_PATH_X86}/install/include" CACHE STRING "Paths to OpenCV include dirs") 21 | set(FFMPEG_INCLUDE_DIRS "$ENV{FFMPEG_PATH_X86}/include" CACHE STRING "Paths to FFMPEG include dirs") 22 | set(VideoSubFinderWXW_LINK_DIRS "$ENV{WX_WIDGETS_PATH}/lib/vc_lib;$ENV{OPENCV_BUILD_PATH_X86}/lib/Release;$ENV{FFMPEG_PATH_X86}/lib" CACHE STRING "VideoSubFinderWXW link dirs") 23 | endif(WIN64) 24 | 25 | set(OpenCV_LIBS "opencv_world$ENV{OPENCV_LIBS_VER}.lib" CACHE STRING "Required OpenCV libs for build") 26 | 27 | else() 28 | option(USE_CUDA "Build with CUDA support" ON) 29 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 30 | set(wxWidgets_USE_DEBUG ON) 31 | else() 32 | set(wxWidgets_USE_DEBUG OFF) 33 | endif() 34 | find_package(wxWidgets REQUIRED COMPONENTS core base aui) 35 | find_package(OpenCV REQUIRED) 36 | if(USE_CUDA) 37 | set(CUDA_LINK_DIRS "$ENV{CUDA_TOOLKIT_PATH}//lib64;$ENV{CUDA_TOOLKIT_PATH}//extras/CUPTI/lib64" CACHE STRING "CUDA link dirs") 38 | endif(USE_CUDA) 39 | endif(WIN32) 40 | 41 | if(USE_CUDA) 42 | set(CMAKE_CUDA_FLAGS "-arch=all") 43 | add_definitions(-DUSE_CUDA) 44 | set(CUDAKernels_INCLUDE_DIRS "../CUDAKernels") 45 | set(CUDAKernels_LIB "CUDAKernels;cudart;nppicc;nppig") 46 | add_subdirectory(Components/CUDAKernels) 47 | else() 48 | set(CUDAKernels_INCLUDE_DIRS "") 49 | set(CUDAKernels_LIB "") 50 | endif(USE_CUDA) 51 | 52 | add_subdirectory(Components/IPAlgorithms) 53 | add_subdirectory(Components/OCVVideo) 54 | add_subdirectory(Components/FFMPEGVideo) 55 | add_subdirectory(Interfaces/VideoSubFinderWXW) 56 | 57 | install(TARGETS VideoSubFinderWXW DESTINATION VideoSubFinder) 58 | install(DIRECTORY Data/bitmaps/ DESTINATION VideoSubFinder/bitmaps) 59 | install(DIRECTORY Settings/Localization/ DESTINATION VideoSubFinder/settings FILES_MATCHING PATTERN "*.cfg") 60 | install(FILES Settings/general.cfg DESTINATION VideoSubFinder/settings) 61 | 62 | file(GLOB readme_files "Docs/readme*.txt") 63 | install(FILES ${readme_files} DESTINATION VideoSubFinder/Docs) 64 | -------------------------------------------------------------------------------- /Components/CUDAKernels/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | project(CUDAKernels LANGUAGES CUDA) 3 | 4 | file(GLOB_RECURSE CUDAKernels_src 5 | "*.h" 6 | "*.cu" 7 | ) 8 | 9 | add_library(CUDAKernels STATIC ${CUDAKernels_src}) 10 | 11 | target_compile_features(CUDAKernels PUBLIC cxx_std_11) 12 | 13 | if (WIN32) 14 | set_target_properties(CUDAKernels PROPERTIES CUDA_ARCHITECTURES all) 15 | else() 16 | set_target_properties(CUDAKernels PROPERTIES CUDA_ARCHITECTURES "50;52;53;60;61;62;70;72;75;80;86;87;89;90") 17 | endif (WIN32) 18 | 19 | target_compile_options(CUDAKernels PRIVATE ${CMAKE_CUDA_FLAGS}) 20 | -------------------------------------------------------------------------------- /Components/CUDAKernels/CUDAKernels.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Components/CUDAKernels/cuda_kernels.cu: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "cuda_kernels.h" 4 | 5 | int GetCUDADeviceCount() 6 | { 7 | int count; 8 | cudaError_t error = cudaGetDeviceCount(&count); 9 | 10 | if (error == cudaSuccess) 11 | { 12 | return count; 13 | } 14 | else 15 | { 16 | return 0; 17 | } 18 | } 19 | 20 | int NV12_to_BGR(unsigned char *src_y, unsigned char *src_uv, int src_linesize, unsigned char *dst_data, int w, int h, int W, int H) 21 | { 22 | NppStatus err; 23 | int nSrcPitchCUDA, res = 0; 24 | 25 | Npp8u* device_nv12[2] = { NULL, NULL }; 26 | Npp8u* device_BGR = NULL; 27 | Npp8u* device_BGR_resized = NULL; 28 | 29 | checkCuda(cudaMalloc(&device_nv12[0], W * H * sizeof(Npp8u))); 30 | checkCuda(cudaMalloc(&device_nv12[1], ((W * H) / 2) * sizeof(Npp8u))); 31 | 32 | checkCuda(cudaMalloc(&device_BGR, W * H * 3 * sizeof(Npp8u))); 33 | 34 | if (w != W) 35 | { 36 | checkCuda(cudaMalloc(&device_BGR_resized, ((w * h) * 3) * sizeof(Npp8u))); 37 | } 38 | 39 | checkCuda(cudaMemcpy(device_nv12[0], src_y, 40 | W * H * sizeof(Npp8u), cudaMemcpyHostToDevice)); 41 | checkCuda(cudaMemcpy(device_nv12[1], src_uv, 42 | ((W * H) / 2) * sizeof(Npp8u), cudaMemcpyHostToDevice)); 43 | 44 | 45 | //err = nppiNV12ToBGR_8u_P2C3R(device_nv12, W, device_BGR, (W * 3), NppiSize{ W, H }); 46 | //err = nppiNV12ToBGR_709HDTV_8u_P2C3R(device_nv12, W, device_BGR, (W * 3), NppiSize{ W, H }); 47 | err = nppiNV12ToBGR_709CSC_8u_P2C3R(device_nv12, W, device_BGR, (W * 3), NppiSize{ W, H }); 48 | 49 | if (err == NPP_SUCCESS) { 50 | if (w != W) { 51 | err = nppiResize_8u_C3R(device_BGR, (W * 3), NppiSize{ W, H }, NppiRect{ 0, 0, W, H }, device_BGR_resized, (w * 3), NppiSize{ w, h }, NppiRect{ 0, 0, w, h }, NPPI_INTER_LINEAR); 52 | } 53 | } 54 | 55 | if (err == NPP_SUCCESS){ 56 | if (w != W) { 57 | checkCuda(cudaMemcpy(dst_data, device_BGR_resized, 58 | ((w * h) * 3) * sizeof(Npp8u), cudaMemcpyDeviceToHost)); 59 | } 60 | else 61 | { 62 | checkCuda(cudaMemcpy(dst_data, device_BGR, 63 | ((w * h) * 3) * sizeof(Npp8u), cudaMemcpyDeviceToHost)); 64 | } 65 | 66 | res = 1; 67 | } 68 | 69 | checkCuda(cudaFree(device_nv12[0])); 70 | checkCuda(cudaFree(device_nv12[1])); 71 | checkCuda(cudaFree(device_BGR)); 72 | if (device_BGR_resized) 73 | { 74 | checkCuda(cudaFree(device_BGR_resized)); 75 | } 76 | 77 | return res; 78 | } 79 | -------------------------------------------------------------------------------- /Components/CUDAKernels/cuda_kernels.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "kmeans/kmeans.h" 4 | 5 | int GetCUDADeviceCount(); 6 | int NV12_to_BGR(unsigned char *src_y, unsigned char *src_uv, int src_linesize, unsigned char *dst_data, int w, int h, int W, int H); 7 | -------------------------------------------------------------------------------- /Components/CUDAKernels/kmeans/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005 Wei-keng Liao 2 | Copyright (c) 2011 Serban Giuroiu 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Components/CUDAKernels/kmeans/kmeans.h: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 | /* File: kmeans.h (an OpenMP version) */ 3 | /* Description: header file for a simple k-means clustering program */ 4 | /* */ 5 | /* Author: Wei-keng Liao */ 6 | /* ECE Department Northwestern University */ 7 | /* email: wkliao@ece.northwestern.edu */ 8 | /* Copyright, 2005, Wei-keng Liao */ 9 | /* */ 10 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 11 | 12 | // Copyright (c) 2005 Wei-keng Liao 13 | // Copyright (c) 2011 Serban Giuroiu 14 | // 15 | // Permission is hereby granted, free of charge, to any person obtaining a copy 16 | // of this software and associated documentation files (the "Software"), to deal 17 | // in the Software without restriction, including without limitation the rights 18 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | // copies of the Software, and to permit persons to whom the Software is 20 | // furnished to do so, subject to the following conditions: 21 | // 22 | // The above copyright notice and this permission notice shall be included in 23 | // all copies or substantial portions of the Software. 24 | // 25 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 | // THE SOFTWARE. 32 | 33 | // ----------------------------------------------------------------------------- 34 | 35 | #ifndef _H_KMEANS 36 | #define _H_KMEANS 37 | 38 | #include 39 | 40 | #define msg(format, ...) do { fprintf(stderr, format, ##__VA_ARGS__); } while (0) 41 | #define err(format, ...) do { fprintf(stderr, format, ##__VA_ARGS__); exit(1); } while (0) 42 | 43 | #define malloc2D(name, xDim, yDim, type) do { \ 44 | name = (type **)malloc(xDim * sizeof(type *)); \ 45 | assert(name != NULL); \ 46 | name[0] = (type *)malloc(xDim * yDim * sizeof(type)); \ 47 | assert(name[0] != NULL); \ 48 | for (size_t i = 1; i < xDim; i++) \ 49 | name[i] = name[i-1] + yDim; \ 50 | } while (0) 51 | 52 | #ifdef __CUDACC__ 53 | inline void checkCuda(cudaError_t e) { 54 | if (e != cudaSuccess) { 55 | // cudaGetErrorString() isn't always very helpful. Look up the error 56 | // number in the cudaError enum in driver_types.h in the CUDA includes 57 | // directory for a better explanation. 58 | err("CUDA Error %d: %s\n", e, cudaGetErrorString(e)); 59 | } 60 | } 61 | 62 | inline void checkLastCudaError() { 63 | checkCuda(cudaGetLastError()); 64 | } 65 | #endif 66 | 67 | float** omp_kmeans(int, float**, int, int, int, float, int*); 68 | float** seq_kmeans(float**, int, int, int, float, int*, int*); 69 | float** cuda_kmeans(float**, int, int, int, float, int*, int); 70 | float** cuda_kmeans_img(unsigned char *imgData, int numObjs, int numClusters, float threshold, int *membership, int loop_iterations); 71 | 72 | float** file_read(int, char*, int*, int*); 73 | int file_write(char*, int, int, int, float**, int*); 74 | 75 | 76 | double wtime(void); 77 | 78 | extern int _debug; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /Components/FFMPEGVideo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB FFMPEGVideo_src 2 | "*.h" 3 | "*.cpp" 4 | ) 5 | 6 | add_library(FFMPEGVideo STATIC ${FFMPEGVideo_src}) 7 | 8 | target_compile_features(FFMPEGVideo PUBLIC cxx_std_17) 9 | 10 | target_include_directories(FFMPEGVideo PUBLIC 11 | "../Include" 12 | "../../Components/IPAlgorithms" 13 | ${wxWidgets_INCLUDE_DIRS} 14 | ${OpenCV_INCLUDE_DIRS} 15 | ${FFMPEG_INCLUDE_DIRS} 16 | ${CUDAKernels_INCLUDE_DIRS} 17 | ) 18 | 19 | if (WIN32) 20 | else() 21 | target_compile_definitions(FFMPEGVideo PUBLIC 22 | ${wxWidgets_DEFINITIONS} 23 | $<$:${wxWidgets_DEFINITIONS_DEBUG}>) 24 | target_compile_options(FFMPEGVideo PRIVATE ${wxWidgets_CXX_FLAGS}) 25 | endif (WIN32) -------------------------------------------------------------------------------- /Components/FFMPEGVideo/FFMPEGVideo.h: -------------------------------------------------------------------------------- 1 | //FFMPEGVideo.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include "DataTypes.h" 20 | #include "Video.h" 21 | #include "opencv2/opencv.hpp" 22 | #include 23 | 24 | extern "C" 25 | { 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | } 37 | 38 | class FFMPEGVideo; 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | 42 | class FFMPEGThreadRunVideo : public wxThread 43 | { 44 | public: 45 | FFMPEGThreadRunVideo(FFMPEGVideo *pVideo); 46 | 47 | virtual void *Entry(); 48 | 49 | public: 50 | FFMPEGVideo *m_pVideo; 51 | }; 52 | 53 | ///////////////////////////////////////////////////////////////////////////// 54 | 55 | class FFMPEGVideo: public CVideo 56 | { 57 | public: 58 | FFMPEGVideo(); 59 | ~FFMPEGVideo(); 60 | 61 | public: 62 | bool m_IsSetNullRender; 63 | 64 | int *m_pBuffer; 65 | int m_BufferSize; 66 | bool m_ImageGeted; 67 | s64 m_st; 68 | int m_type; //video open type 69 | bool m_show_video; 70 | double m_frameNumbers; 71 | double m_fps; 72 | long m_origWidth; 73 | long m_origHeight; 74 | 75 | FFMPEGThreadRunVideo *m_pThreadRunVideo; 76 | 77 | int64_t m_start_pts = 0; 78 | 79 | AVFilterGraph *filter_graph = NULL; 80 | AVFilterContext *buffersink_ctx = NULL; 81 | AVFilterContext *buffersrc_ctx = NULL; 82 | 83 | AVFormatContext *input_ctx = NULL; 84 | AVBufferRef *hw_device_ctx = NULL; 85 | AVCodecContext *decoder_ctx = NULL; 86 | AVStream *video = NULL; 87 | #if LIBAVFORMAT_VERSION_MAJOR > 58 88 | const AVCodec *decoder = NULL; 89 | #else 90 | AVCodec *decoder = NULL; 91 | #endif 92 | AVFrame *frame = NULL; 93 | AVFrame *sw_frame = NULL; 94 | AVFrame* filt_frame = NULL; 95 | int video_stream; 96 | int64_t m_cur_pts; 97 | s64 m_dt_search; 98 | s64 m_dt; 99 | 100 | int m_frame_buffer_size = -1; 101 | simple_buffer m_frame_buffer; 102 | 103 | AVPacket packet; 104 | 105 | bool need_to_read_packet = true; 106 | bool cuda_memory_is_initialized = false; 107 | 108 | AVPixelFormat src_fmt; 109 | 110 | //DWORD min_dt = 1000; 111 | //DWORD max_dt = 0; 112 | 113 | public: 114 | void ShowFrame(void *dc = NULL); 115 | 116 | bool OpenMovie(wxString csMovieName, void *pVideoWindow, int type); 117 | 118 | bool SetVideoWindowPlacement(void *pVideoWindow); 119 | bool SetNullRender(); 120 | 121 | bool CloseMovie(); 122 | 123 | void SetPos(s64 Pos); 124 | void SetPos(double pos); 125 | void SetPosFast(s64 Pos); 126 | 127 | void SetImageGeted(bool ImageGeted); 128 | 129 | void Run(); 130 | void Pause(); 131 | 132 | void WaitForCompletion(s64 timeout); 133 | 134 | void StopFast(); 135 | 136 | void RunWithTimeout(s64 timeout); 137 | 138 | void Stop(); 139 | void OneStep(); 140 | s64 OneStepWithTimeout(); 141 | s64 GetPos(); 142 | void GetBGRImage(simple_buffer& ImBGR, int xmin, int xmax, int ymin, int ymax); 143 | int ConvertToBGR(u8* frame_data, simple_buffer& ImBGR, int xmin, int xmax, int ymin, int ymax); 144 | inline int convert_to_dst_format(u8* frame_data, uint8_t* const dst_data[], const int dst_linesize[], AVPixelFormat dest_fmt); 145 | 146 | int GetFrameDataSize(); 147 | void GetFrameData(simple_buffer& FrameData); 148 | 149 | void SetVideoWindowPosition(int left, int top, int width, int height, void *dc); 150 | 151 | void ErrorMessage(wxString str); 152 | 153 | int hw_decoder_init(AVCodecContext *ctx, const enum AVHWDeviceType type); 154 | int decode_frame(s64& frame_pos); 155 | int init_filters(); 156 | }; 157 | -------------------------------------------------------------------------------- /Components/FFMPEGVideo/FFMPEGVideo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Components/FFMPEGVideo/FFMPEGVideoLoader.cpp: -------------------------------------------------------------------------------- 1 | //FFMPEGVideoLoader.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | //#include "stdafx.h" 18 | #include "FFMPEGVideoLoader.h" 19 | #include "FFMPEGVideo.h" 20 | 21 | FFMPEGVideo g_FFMPEGVideo; 22 | 23 | ///////////////////////////////////////////////////////////////////////////// 24 | 25 | CVideo* GetFFMPEGVideoObject() 26 | { 27 | return &g_FFMPEGVideo; 28 | } -------------------------------------------------------------------------------- /Components/FFMPEGVideo/FFMPEGVideoLoader.h: -------------------------------------------------------------------------------- 1 | //FFMPEGVideoLoader.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include "Video.h" 20 | #include 21 | 22 | extern wxString g_hw_device; 23 | extern wxString g_filter_descr; 24 | 25 | wxArrayString GetAvailableHWDeviceTypes(); 26 | CVideo* GetFFMPEGVideoObject(); 27 | -------------------------------------------------------------------------------- /Components/IPAlgorithms/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB IPAlgorithms_src 2 | "*.h" 3 | "*.cpp" 4 | ) 5 | 6 | add_library(IPAlgorithms STATIC ${IPAlgorithms_src}) 7 | 8 | target_compile_features(IPAlgorithms PUBLIC cxx_std_17) 9 | 10 | target_include_directories(IPAlgorithms PUBLIC 11 | "../Include" 12 | ${wxWidgets_INCLUDE_DIRS} 13 | ${OpenCV_INCLUDE_DIRS} 14 | ${CUDAKernels_INCLUDE_DIRS} 15 | ) 16 | 17 | if (WIN32) 18 | else() 19 | target_compile_definitions(IPAlgorithms PUBLIC 20 | ${wxWidgets_DEFINITIONS} 21 | $<$:${wxWidgets_DEFINITIONS_DEBUG}>) 22 | target_compile_options(IPAlgorithms PRIVATE ${wxWidgets_CXX_FLAGS}) 23 | endif (WIN32) 24 | 25 | 26 | -------------------------------------------------------------------------------- /Components/IPAlgorithms/IPAlgorithms.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Components/IPAlgorithms/MyClosedFigure.cpp: -------------------------------------------------------------------------------- 1 | //MyClosedFigure.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #include "MyClosedFigure.h" 18 | #include 19 | 20 | using namespace std; 21 | 22 | CMyClosedFigure::CMyClosedFigure() 23 | { 24 | } 25 | 26 | CMyClosedFigure::~CMyClosedFigure() 27 | { 28 | } 29 | 30 | void CMyClosedFigure::operator=(CMyClosedFigure& other) 31 | { 32 | m_PointsArray = other.m_PointsArray; 33 | m_minX = other.m_minX; 34 | m_maxX = other.m_maxX; 35 | m_minY = other.m_minY; 36 | m_maxY = other.m_maxY; 37 | } 38 | 39 | void CMyClosedFigure::operator+=(CMyClosedFigure& other) 40 | { 41 | m_PointsArray += other.m_PointsArray; 42 | if (other.m_minX < m_minX) m_minX = other.m_minX; 43 | if (other.m_maxX > m_maxX) m_maxX = other.m_maxX; 44 | if (other.m_minY < m_minY) m_minY = other.m_minY; 45 | if (other.m_maxY > m_maxY) m_maxY = other.m_maxY; 46 | } 47 | -------------------------------------------------------------------------------- /Components/IPAlgorithms/MyClosedFigure.h: -------------------------------------------------------------------------------- 1 | //MyClosedFigure.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include "DataTypes.h" 20 | #include 21 | #include 22 | 23 | using namespace std; 24 | 25 | class CMyClosedFigure 26 | { 27 | public: 28 | simple_buffer m_PointsArray; 29 | 30 | u16 m_minX; 31 | u16 m_maxX; 32 | u16 m_minY; 33 | u16 m_maxY; 34 | 35 | CMyClosedFigure(); 36 | ~CMyClosedFigure(); 37 | 38 | inline int width() { 39 | return (int)(m_maxX - m_minX + 1); 40 | } 41 | 42 | inline int height() { 43 | return (int)(m_maxY - m_minY + 1); 44 | } 45 | 46 | void operator=(CMyClosedFigure& other); 47 | void operator+=(CMyClosedFigure& other); 48 | }; 49 | 50 | template 51 | u64 SearchClosedFigures(simple_buffer &Im, int w, int h, T white, custom_buffer &FiguresArray, bool combine_diagonal_points = true); 52 | 53 | //----------------------------------------------------- 54 | 55 | template 56 | void GetInfoAboutNearestPoints(simple_buffer& Im, int& x, int& y, int& i, int& w, bool& bln, bool& bln2, int& i1, int& i2, T& white, bool combine_diagonal_points) 57 | { 58 | if (combine_diagonal_points) 59 | { 60 | //Проверяем есть ли с лева точка фигуры 61 | if ((x > 0) && (Im[i - 1] == white))//[x-1][y] 62 | {//есть: 63 | bln = true; 64 | i1 = i - 1; 65 | 66 | if (y > 0) 67 | { 68 | //Проверяем нет ли c низу с лева точки фигуры 69 | if (Im[i - w - 1] != white)//[x-1][y-1] 70 | {//с низу с лева точки фигуры нету: 71 | 72 | //Проверяем есть ли с низу точка фигуры 73 | if (Im[i - w] == white)//[x][y-1] 74 | {//есть: 75 | bln2 = true; 76 | i2 = i - w; 77 | } 78 | else 79 | {//нету: 80 | 81 | //Проверяем есть ли с низу с права точка фигуры 82 | if (x < w - 1) 83 | { 84 | if (Im[i - w + 1] == white)//[x+1][y-1] 85 | {//есть: 86 | bln2 = true; 87 | i2 = i - w + 1; 88 | } 89 | } 90 | } 91 | } 92 | else 93 | {//с низу с лева точка фигуры есть: 94 | 95 | //Проверяем нет ли с низу точки фигуры 96 | if (Im[i - w] != white)//[x][y-1] 97 | {//нет: 98 | 99 | //Проверяем есть ли с низу с права точка фигуры 100 | if (x < w - 1) 101 | { 102 | if (Im[i - w + 1] == white)//[x+1][y-1] 103 | {//есть: 104 | bln2 = true; 105 | i2 = i - w + 1; 106 | } 107 | } 108 | } 109 | } 110 | } 111 | } 112 | else 113 | {//с лева точки фигуры нету: 114 | 115 | if (y > 0) 116 | { 117 | //Проверяем есть ли с низу точка фигуры 118 | if (Im[i - w] == white)//[x][y-1] 119 | {//есть: 120 | bln = true; 121 | i1 = i - w; 122 | } 123 | else 124 | {//нету: 125 | 126 | //Проверяем есть ли снизу слева точка фигуры 127 | if ((x > 0) && (Im[i - w - 1] == white))//[x-1][y-1] 128 | {//есть: 129 | bln = true; 130 | i1 = i - w - 1; 131 | 132 | //Проверяем есть ли снизу справа точка фигуры 133 | if (x < w - 1) 134 | { 135 | if (Im[i - w + 1] == white)//[x+1][y-1] 136 | { 137 | //есть: 138 | bln2 = true; 139 | i2 = i - w + 1; 140 | } 141 | } 142 | } 143 | else 144 | {//нету: 145 | 146 | //Проверяем есть ли снизу справа точка фигуры 147 | if (x < w - 1) 148 | { 149 | if (Im[i - w + 1] == white)//[x+1][y-1] 150 | { 151 | //есть: 152 | bln = true; 153 | i1 = i - w + 1; 154 | } 155 | } 156 | } 157 | } 158 | } 159 | } 160 | } 161 | else 162 | { 163 | //Проверяем есть ли с лева точка фигуры 164 | if ((x > 0) && (Im[i - 1] == white))//[x-1][y] 165 | {//есть: 166 | bln = true; 167 | i1 = i - 1; 168 | 169 | if (y > 0) 170 | { 171 | //Проверяем нет ли c низу с лева точки фигуры 172 | if (Im[i - w - 1] != white)//[x-1][y-1] 173 | {//с низу с лева точки фигуры нету: 174 | 175 | //Проверяем есть ли с низу точка фигуры 176 | if (Im[i - w] == white)//[x][y-1] 177 | {//есть: 178 | bln2 = true; 179 | i2 = i - w; 180 | } 181 | /*else 182 | {//нету: 183 | 184 | //Проверяем есть ли с низу с права точка фигуры 185 | if (x < w - 1) 186 | { 187 | if (Im[i - w + 1] == white)//[x+1][y-1] 188 | {//есть: 189 | bln2 = true; 190 | i2 = i - w + 1; 191 | } 192 | } 193 | }*/ 194 | } 195 | /*else 196 | {//с низу с лева точка фигуры есть: 197 | 198 | //Проверяем нет ли с низу точки фигуры 199 | if (Im[i - w] != white)//[x][y-1] 200 | {//нет: 201 | 202 | //Проверяем есть ли с низу с права точка фигуры 203 | if (x < w - 1) 204 | { 205 | if (Im[i - w + 1] == white)//[x+1][y-1] 206 | {//есть: 207 | bln2 = true; 208 | i2 = i - w + 1; 209 | } 210 | } 211 | } 212 | }*/ 213 | } 214 | } 215 | else 216 | {//с лева точки фигуры нету: 217 | 218 | if (y > 0) 219 | { 220 | //Проверяем есть ли с низу точка фигуры 221 | if (Im[i - w] == white)//[x][y-1] 222 | {//есть: 223 | bln = true; 224 | i1 = i - w; 225 | } 226 | /*else 227 | {//нету: 228 | 229 | //Проверяем есть ли снизу слева точка фигуры 230 | if ((x > 0) && (Im[i - w - 1] == white))//[x-1][y-1] 231 | {//есть: 232 | bln = true; 233 | i1 = i - w - 1; 234 | 235 | //Проверяем есть ли снизу справа точка фигуры 236 | if (x < w - 1) 237 | { 238 | if (Im[i - w + 1] == white)//[x+1][y-1] 239 | { 240 | //есть: 241 | bln2 = true; 242 | i2 = i - w + 1; 243 | } 244 | } 245 | } 246 | else 247 | {//нету: 248 | 249 | //Проверяем есть ли снизу справа точка фигуры 250 | if (x < w - 1) 251 | { 252 | if (Im[i - w + 1] == white)//[x+1][y-1] 253 | { 254 | //есть: 255 | bln = true; 256 | i1 = i - w + 1; 257 | } 258 | } 259 | } 260 | }*/ 261 | } 262 | } 263 | } 264 | } 265 | 266 | ///////////////////////////////////////////////////////////////////////////// 267 | 268 | template 269 | u64 SearchClosedFigures(simple_buffer& Im, int w, int h, T white, custom_buffer& FiguresArray, bool combine_diagonal_points) 270 | { 271 | int* m, * key, * key2, * max_index_in_split; 272 | const int n_splits = 1; 273 | const int size = w * h; 274 | //std::chrono::time_point start; 275 | 276 | //start = std::chrono::high_resolution_clock::now(); 277 | 278 | m = new int[size]; 279 | key = new int[size]; 280 | key2 = new int[size]; 281 | max_index_in_split = new int[n_splits]; 282 | 283 | //Finding all closed figures on image 284 | 285 | // doesn't give difference with n_splits == 32 (work a little longer) 286 | // std::for_each(std::execution::par, ForwardIteratorForDefineRange(0), ForwardIteratorForDefineRange(n_splits), [&](int i_split) 287 | //{ 288 | for (int i_split = 0; i_split < n_splits; i_split++) 289 | { 290 | int i, j, i1, i2, jj, kk; 291 | int x, y; 292 | bool bln, bln2; 293 | custom_assert(n_splits > 0, "SearchClosedFigures: n_splits > 0"); 294 | int yb = i_split * (h / n_splits); 295 | int ye = (i_split == n_splits - 1) ? (h - 1) : (yb + (h / n_splits) - 1); 296 | int hh = ye - yb + 1; 297 | int index = yb * w + 1; 298 | 299 | for (y = 0, i = yb * w; y < hh; y++) 300 | { 301 | for (x = 0; x < w; x++, i++) 302 | { 303 | if (Im[i] == white) 304 | { 305 | bln = false; 306 | bln2 = false; 307 | 308 | GetInfoAboutNearestPoints(Im, x, y, i, w, bln, bln2, i1, i2, white, combine_diagonal_points); 309 | 310 | if (bln) 311 | { 312 | m[i] = m[i1]; 313 | } 314 | else 315 | { 316 | m[i] = index; 317 | key[index] = index; 318 | key2[index] = index; 319 | index++; 320 | } 321 | 322 | if (bln2) 323 | { 324 | if (m[i1] != m[i2]) 325 | { 326 | jj = max(m[i1], m[i2]); 327 | kk = min(m[i1], m[i2]); 328 | while (key[jj] != jj) jj = key[jj]; 329 | while (key[kk] != kk) kk = key[kk]; 330 | key[max(jj, kk)] = min(jj, kk); 331 | } 332 | } 333 | } 334 | } 335 | } 336 | 337 | max_index_in_split[i_split] = index; 338 | }//); 339 | 340 | for (int i_split = 1; i_split < n_splits; i_split++) 341 | { 342 | int i, j, i1, i2, jj, kk; 343 | custom_assert(n_splits > 0, "SearchClosedFigures: n_splits > 0"); 344 | int x, y = i_split * (h / n_splits); 345 | bool bln, bln2; 346 | 347 | for (x = 0, i = y * w; x < w; x++, i++) 348 | { 349 | if (Im[i] == white) 350 | { 351 | bln = false; 352 | bln2 = false; 353 | 354 | GetInfoAboutNearestPoints(Im, x, y, i, w, bln, bln2, i1, i2, white, combine_diagonal_points); 355 | 356 | if (bln) 357 | { 358 | if (m[i] != m[i1]) 359 | { 360 | jj = max(m[i], m[i1]); 361 | kk = min(m[i], m[i1]); 362 | while (key[jj] != jj) jj = key[jj]; 363 | while (key[kk] != kk) kk = key[kk]; 364 | key[max(jj, kk)] = min(jj, kk); 365 | } 366 | } 367 | 368 | if (bln2) 369 | { 370 | if (m[i1] != m[i2]) 371 | { 372 | jj = max(m[i1], m[i2]); 373 | kk = min(m[i1], m[i2]); 374 | while (key[jj] != jj) jj = key[jj]; 375 | while (key[kk] != kk) kk = key[kk]; 376 | key[max(jj, kk)] = min(jj, kk); 377 | } 378 | } 379 | } 380 | } 381 | 382 | } 383 | 384 | int i, j, x, y, N = 0; 385 | 386 | for (int i_split = 0; i_split < n_splits; i_split++) 387 | { 388 | custom_assert(n_splits > 0, "SearchClosedFigures: n_splits > 0"); 389 | int yb = i_split * (h / n_splits); 390 | int index_min = yb * w + 1; 391 | 392 | for (i = index_min; i < max_index_in_split[i_split]; i++) 393 | { 394 | j = i; 395 | while (key[j] != j) j = key[j]; 396 | key[i] = j; 397 | 398 | if (key[i] == i) 399 | { 400 | key2[i] = N; 401 | N++; 402 | } 403 | } 404 | } 405 | 406 | for (int i_split = 0; i_split < n_splits; i_split++) 407 | { 408 | custom_assert(n_splits > 0, "SearchClosedFigures: n_splits > 0"); 409 | int yb = i_split * (h / n_splits); 410 | int index_min = yb * w + 1; 411 | 412 | for (i = index_min; i < max_index_in_split[i_split]; i++) 413 | { 414 | key[i] = key2[key[i]]; 415 | } 416 | } 417 | 418 | int* NN, * I, * minX, * maxX, * minY, * maxY; 419 | 420 | NN = new int[N]; 421 | I = new int[N]; 422 | minX = new int[N]; 423 | maxX = new int[N]; 424 | minY = new int[N]; 425 | maxY = new int[N]; 426 | 427 | for (i = 0; i < N; i++) 428 | { 429 | NN[i] = 0; 430 | I[i] = 0; 431 | minX[i] = w; 432 | maxX[i] = 0; 433 | minY[i] = h; 434 | maxY[i] = 0; 435 | } 436 | 437 | for (y = 0, i = 0; y < h; y++) 438 | { 439 | for (x = 0; x < w; x++, i++) 440 | { 441 | if (Im[i] == white) 442 | { 443 | j = key[m[i]]; 444 | NN[j]++; 445 | maxY[j] = y; 446 | if (minY[j] > y) minY[j] = y; 447 | if (maxX[j] < x) maxX[j] = x; 448 | if (minX[j] > x) minX[j] = x; 449 | } 450 | } 451 | } 452 | FiguresArray.set_size(N); 453 | 454 | CMyClosedFigure* pf; 455 | 456 | for (i = 0; i < N; i++) 457 | { 458 | pf = &(FiguresArray[i]); 459 | pf->m_PointsArray.set_size(NN[i]); 460 | pf->m_minX = minX[i]; 461 | pf->m_maxX = maxX[i]; 462 | pf->m_minY = minY[i]; 463 | pf->m_maxY = maxY[i]; 464 | } 465 | 466 | for (y = 0, i = 0; y < h; y++) 467 | { 468 | for (x = 0; x < w; x++, i++) 469 | { 470 | if (Im[i] == white) 471 | { 472 | j = key[m[i]]; 473 | FiguresArray[j].m_PointsArray[I[j]] = i; 474 | I[j]++; 475 | } 476 | } 477 | } 478 | 479 | delete[] m; 480 | delete[] key; 481 | delete[] key2; 482 | delete[] NN; 483 | delete[] I; 484 | delete[] minX; 485 | delete[] maxX; 486 | delete[] minY; 487 | delete[] maxY; 488 | delete[] max_index_in_split; 489 | 490 | return 1/*(std::chrono::high_resolution_clock::now() - start)*/; 491 | } 492 | 493 | -------------------------------------------------------------------------------- /Components/IPAlgorithms/SSAlgorithms.h: -------------------------------------------------------------------------------- 1 | //SSAlgorithms.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include "IPAlgorithms.h" 20 | #include "DataTypes.h" 21 | #include "MyClosedFigure.h" 22 | #include "Video.h" 23 | #include 24 | #include 25 | 26 | using namespace std; 27 | 28 | extern std::chrono::time_point g_StartTimeRunSubSearch; 29 | extern int g_RunSubSearch; 30 | 31 | extern int g_threads; // number of threads 32 | extern int g_DL; //sub frame length 33 | extern double g_tp; //text percent 34 | extern double g_mtpl; //min text len (in percent) 35 | extern double g_veple; //vedges points line error 36 | extern double g_ilaple; //ILA points line error 37 | 38 | extern bool g_use_ISA_images_for_search_subtitles; 39 | extern bool g_use_ILA_images_for_search_subtitles; 40 | extern bool g_replace_ISA_by_filtered_version; 41 | extern int g_max_dl_down; 42 | extern int g_max_dl_up; 43 | 44 | s64 FastSearchSubtitles(CVideo *pV, s64 Begin, s64 End); 45 | 46 | int AnalyseImage(simple_buffer &Im, simple_buffer *pImILA, int w, int h); 47 | 48 | int CompareTwoSubs(simple_buffer &Im1, simple_buffer *pImILA1, simple_buffer &ImVE11, simple_buffer &ImVE12, simple_buffer &Im2, simple_buffer *pImILA2, simple_buffer &ImVE2, int w, int h, int W, int H, wxString iter_det); 49 | 50 | int DifficultCompareTwoSubs2(simple_buffer &ImF1, simple_buffer *pImILA1, simple_buffer &ImNE11, simple_buffer &ImNE12, simple_buffer &ImF2, simple_buffer *pImILA2, simple_buffer &ImNE2, int w, int h, int W, int H, int min_x, int max_x, wxString iter_det); 51 | 52 | int CompareTwoSubsOptimal(simple_buffer &Im1, simple_buffer *pImILA1, simple_buffer &ImVE11, simple_buffer &ImVE12, simple_buffer &Im2, simple_buffer *pImILA2, simple_buffer &ImVE2, int w, int h, int W, int H, int min_x, int max_x, wxString iter_det); 53 | 54 | template 55 | void AddTwoImages(simple_buffer &Im1, simple_buffer &Im2, simple_buffer &ImRES, int size); 56 | template 57 | void AddTwoImages(simple_buffer &Im1, simple_buffer &Im2, int size); 58 | 59 | void ImBGRToNativeSize(simple_buffer &ImBGROrig, simple_buffer &ImBGRRes, int w, int h, int W, int H, int xmin, int xmax, int ymin, int ymax); 60 | 61 | wxString VideoTimeToStr(s64 pos); 62 | s64 GetVideoTime(wxString time); 63 | s64 GetVideoTime(int minute, int sec, int mili_sec); 64 | 65 | wxString GetFileName(wxString FilePath); 66 | wxString GetFileExtension(wxString FilePath); 67 | wxString GetFileNameWithExtension(wxString FilePath); 68 | wxString GetFileDir(wxString FilePath); 69 | 70 | // W - full image include scale (if is) width 71 | // H - full image include scale (if is) height 72 | template 73 | void ImToNativeSize(simple_buffer& ImOrig, simple_buffer& ImRes, int w, int h, int W, int H, int xmin, int xmax, int ymin, int ymax) 74 | { 75 | int i, j, dj, x, y; 76 | 77 | custom_assert(ImRes.m_size >= W * H, "ImToNativeSize: Im.m_size >= W*H"); 78 | memset(ImRes.m_pData, 255, W * H * sizeof(T)); 79 | 80 | i = 0; 81 | j = ymin * W + xmin; 82 | for (y = 0; y < h; y++) 83 | { 84 | ImRes.copy_data(ImOrig, j, i, w); 85 | i += w; 86 | j += W; 87 | } 88 | } 89 | 90 | 91 | // W - full image include scale (if is) width 92 | // H - full image include scale (if is) height 93 | template 94 | void ImToNativeSize(simple_buffer& Im, int w, int h, int W, int H, int xmin, int xmax, int ymin, int ymax) 95 | { 96 | simple_buffer ImTMP(Im, 0, w*h); 97 | ImToNativeSize(ImTMP, Im, w, h, W, H, xmin, xmax, ymin, ymax); 98 | } -------------------------------------------------------------------------------- /Components/Include/Video.h: -------------------------------------------------------------------------------- 1 | //Video.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include "DataTypes.h" 20 | #include 21 | 22 | using namespace std; 23 | 24 | class CVideo 25 | { 26 | public: 27 | CVideo() 28 | { 29 | m_MovieName = ""; 30 | m_Inited = false; 31 | m_Width = 0; 32 | m_Height = 0; 33 | m_Duration = 0; 34 | m_log = ""; 35 | m_Dir = ""; 36 | } 37 | 38 | virtual ~CVideo() 39 | { 40 | } 41 | 42 | public: 43 | bool m_play_video; 44 | 45 | wxString m_MovieName; 46 | bool m_Inited; 47 | 48 | long m_Width; 49 | long m_Height; 50 | 51 | s64 m_Duration; 52 | s64 m_Pos; 53 | 54 | wxString m_log; 55 | wxString m_Dir; 56 | void *m_pVideoWindow; 57 | 58 | // VideoWindowSettins 59 | int m_xmin; 60 | int m_xmax; 61 | int m_ymin; 62 | int m_ymax; 63 | int m_w; 64 | int m_h; 65 | 66 | public: 67 | 68 | void SetVideoWindowSettins(double dx_min, double dx_max, double dy_min, double dy_max) 69 | { 70 | m_xmin = (int)(dx_min*(double)m_Width); 71 | m_xmax = (int)(dx_max*(double)m_Width) - 1; 72 | m_ymin = (int)(dy_min*(double)m_Height); 73 | m_ymax = (int)(dy_max*(double)m_Height) - 1; 74 | 75 | m_w = m_xmax - m_xmin + 1; 76 | m_h = m_ymax - m_ymin + 1; 77 | } 78 | 79 | virtual bool OpenMovie(wxString csMovieName, void *pVideoWindow, int type) 80 | { 81 | return false; 82 | } 83 | 84 | virtual bool SetVideoWindowPlacement(void *pVideoWindow) 85 | { 86 | return false; 87 | } 88 | 89 | virtual bool SetNullRender() 90 | { 91 | return false; 92 | } 93 | 94 | virtual bool CloseMovie() 95 | { 96 | return false; 97 | } 98 | 99 | virtual void SetPos(s64 Pos) 100 | { 101 | } 102 | 103 | virtual void SetPos(double pos) 104 | { 105 | } 106 | 107 | virtual void SetPosFast(s64 Pos) 108 | { 109 | } 110 | 111 | virtual void SetImageGeted(bool ImageGeted) 112 | { 113 | } 114 | 115 | virtual void Run() 116 | { 117 | } 118 | 119 | virtual void Pause() 120 | { 121 | } 122 | 123 | virtual void WaitForCompletion(s64 timeout) 124 | { 125 | } 126 | 127 | virtual void StopFast() 128 | { 129 | } 130 | 131 | virtual void RunWithTimeout(s64 timeout) 132 | { 133 | } 134 | 135 | virtual void Stop() 136 | { 137 | } 138 | 139 | virtual void OneStep() 140 | { 141 | } 142 | 143 | virtual s64 OneStepWithTimeout() 144 | { 145 | return 0; 146 | } 147 | 148 | virtual s64 GetPos() 149 | { 150 | return 0; 151 | } 152 | 153 | virtual void GetBGRImage(simple_buffer& ImBGR, int xmin, int xmax, int ymin, int ymax) 154 | { 155 | } 156 | 157 | virtual int ConvertToBGR(u8* frame_data, simple_buffer& ImBGR, int xmin, int xmax, int ymin, int ymax) 158 | { 159 | return -1; 160 | } 161 | 162 | virtual int GetFrameDataSize() 163 | { 164 | return 0; 165 | } 166 | 167 | virtual void GetFrameData(simple_buffer& FrameData) 168 | { 169 | } 170 | 171 | virtual void SetVideoWindowPosition(int left, int top, int width, int height, void *dc) 172 | { 173 | } 174 | }; 175 | 176 | extern CVideo *g_pV; 177 | 178 | extern wxString ConvertVideoTime(s64 pos); 179 | -------------------------------------------------------------------------------- /Components/OCVVideo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB OCVVideo_src 2 | "*.h" 3 | "*.cpp" 4 | ) 5 | 6 | add_library(OCVVideo STATIC ${OCVVideo_src}) 7 | 8 | target_compile_features(OCVVideo PUBLIC cxx_std_17) 9 | 10 | target_include_directories(OCVVideo PUBLIC 11 | "../Include" 12 | ${wxWidgets_INCLUDE_DIRS} 13 | ${OpenCV_INCLUDE_DIRS} 14 | ) 15 | 16 | if (WIN32) 17 | else() 18 | 19 | target_compile_definitions(OCVVideo PUBLIC 20 | ${wxWidgets_DEFINITIONS} 21 | $<$:${wxWidgets_DEFINITIONS_DEBUG}>) 22 | target_compile_options(OCVVideo PRIVATE ${wxWidgets_CXX_FLAGS}) 23 | endif (WIN32) -------------------------------------------------------------------------------- /Components/OCVVideo/OCVVideo.h: -------------------------------------------------------------------------------- 1 | //OCVVideo.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include "DataTypes.h" 20 | #include "Video.h" 21 | #include "opencv2/opencv.hpp" 22 | #include 23 | #include 24 | 25 | class OCVVideo; 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | 29 | class ThreadRunVideo : public wxThread 30 | { 31 | public: 32 | ThreadRunVideo(OCVVideo *pVideo); 33 | 34 | virtual void *Entry(); 35 | 36 | public: 37 | OCVVideo *m_pVideo; 38 | }; 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | 42 | class OCVVideo: public CVideo 43 | { 44 | public: 45 | OCVVideo(); 46 | ~OCVVideo(); 47 | 48 | public: 49 | bool m_IsSetNullRender; 50 | 51 | cv::VideoCapture m_VC; 52 | 53 | int *m_pBuffer; 54 | int m_BufferSize; 55 | bool m_ImageGeted; 56 | s64 m_st; 57 | int m_type; //video open type 58 | bool m_show_video; 59 | wxBitmap *m_pBmp; 60 | wxBitmap *m_pBmpScaled; 61 | double m_frameNumbers; 62 | double m_fps; 63 | cv::Mat m_cur_frame; 64 | long m_origWidth; 65 | long m_origHeight; 66 | 67 | ThreadRunVideo *m_pThreadRunVideo; 68 | std::mutex m_run_mutex; 69 | std::mutex m_pause_mutex; 70 | 71 | public: 72 | void ShowFrame(cv::Mat &img, void *dc = NULL, int left = -1, int top = -1, int width = -1, int height = -1); 73 | 74 | bool OpenMovie(wxString csMovieName, void *pVideoWindow, int type); 75 | 76 | bool SetVideoWindowPlacement(void *pVideoWindow); 77 | bool SetNullRender(); 78 | 79 | bool CloseMovie(); 80 | 81 | void SetPos(s64 Pos); 82 | void SetPos(double pos); 83 | void SetPosFast(s64 Pos); 84 | 85 | void SetImageGeted(bool ImageGeted); 86 | 87 | void Run(); 88 | void Pause(); 89 | 90 | void WaitForCompletion(s64 timeout); 91 | 92 | void StopFast(); 93 | 94 | void RunWithTimeout(s64 timeout); 95 | 96 | void Stop(); 97 | void OneStep(); 98 | s64 OneStepWithTimeout(); 99 | s64 GetPos(); 100 | 101 | void GetBGRImage(simple_buffer& ImBGR, int xmin, int xmax, int ymin, int ymax); 102 | int ConvertToBGR(u8* frame_data, simple_buffer& ImBGR, int xmin, int xmax, int ymin, int ymax); 103 | 104 | int GetFrameDataSize(); 105 | void GetFrameData(simple_buffer& FrameData); 106 | 107 | void SetVideoWindowPosition(int left, int top, int width, int height, void *dc); 108 | 109 | void ErrorMessage(wxString str); 110 | }; 111 | -------------------------------------------------------------------------------- /Components/OCVVideo/OCVVideo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Components/OCVVideo/OCVVideoLoader.cpp: -------------------------------------------------------------------------------- 1 | //OCVVideoLoader.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | //#include "stdafx.h" 18 | #include "OCVVideo.h" 19 | 20 | OCVVideo g_OCVVideo; 21 | 22 | ///////////////////////////////////////////////////////////////////////////// 23 | 24 | CVideo* GetOCVVideoObject() 25 | { 26 | return &g_OCVVideo; 27 | } -------------------------------------------------------------------------------- /Components/OCVVideo/OCVVideoLoader.h: -------------------------------------------------------------------------------- 1 | //OCVVideoLoader.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include "Video.h" 20 | 21 | CVideo* GetOCVVideoObject(); 22 | -------------------------------------------------------------------------------- /Data/bitmaps/left_na.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/left_na.bmp -------------------------------------------------------------------------------- /Data/bitmaps/left_od.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/left_od.bmp -------------------------------------------------------------------------------- /Data/bitmaps/right_na.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/right_na.bmp -------------------------------------------------------------------------------- /Data/bitmaps/right_od.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/right_od.bmp -------------------------------------------------------------------------------- /Data/bitmaps/sb_la.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/sb_la.bmp -------------------------------------------------------------------------------- /Data/bitmaps/sb_lc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/sb_lc.bmp -------------------------------------------------------------------------------- /Data/bitmaps/sb_ra.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/sb_ra.bmp -------------------------------------------------------------------------------- /Data/bitmaps/sb_rc.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/sb_rc.bmp -------------------------------------------------------------------------------- /Data/bitmaps/sb_t.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/sb_t.bmp -------------------------------------------------------------------------------- /Data/bitmaps/tb_pause.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/tb_pause.bmp -------------------------------------------------------------------------------- /Data/bitmaps/tb_run.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/tb_run.bmp -------------------------------------------------------------------------------- /Data/bitmaps/tb_stop.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Data/bitmaps/tb_stop.bmp -------------------------------------------------------------------------------- /Docs/readme_chn.txt: -------------------------------------------------------------------------------- 1 | 中文教程实时更新:https://docs.qq.com/doc/DRk9HWWlXdkRFa05o?&u=146bab4d9f414c3693447729af1de915 2 | 3 | #--------------------关于程序-------------------- 4 | 5 | 程序主要提供两个功能: 6 | 1)通过数字图像处理算法,自动检测视频中带有硬字幕的帧,生成只带有时间轴的空白字幕; 7 | 2)通过文本挖掘算法,用带有硬字幕的图片生成图形文字。可以用其他软件来进一步识别,如FineReader和Subtitle Edit,生成既有文本又有时间轴的字幕。 8 | 9 | 为了使程序正常运行,需要下载安装"Microsoft Visual C++ Redistributable runtime libraries 2022", 10 | 下载地址:https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads 11 | 最新版本测试基于Windows 10 x64, Ubuntu 20.04.5 LTS, Arch Linux (EndeavourOS Cassini Nova 03-2023) 12 | 13 | 获得快速支持:https://vk.com/skosnits 14 | 15 | #--------------------快速入门指南-------------------- 16 | 17 | 1)点击菜单栏<<文件->打开视频>>(推荐使用OpenCV,提取的时间轴准确性更高); 18 | 2)在<<视频预览框>>中,通过移动垂直和水平分隔线来缩小检测区域,使结果更准确、时间轴更完整; 19 | 3)确认字幕在检测区域内的水平对齐方式:居中/左对齐/右对齐/任意位置,在<<设置>>标签页里的<<文本对齐方式>>中选择对应属性 20 | 4)强烈推荐使用<<字幕颜色滤镜>>来提高识别结果准确率,该步骤可以跳过: 21 | *- 拖动进度条,找到带有字幕的图像 22 | *- 鼠标点击<<视频预览框>>任意位置,选中后按"U",全屏查看图片,鼠标左键点击字幕像素点,即可获取字幕的颜色信息 23 | *- 字幕颜色信息在<<设置>>标签页中的右下角,复制Lab颜色信息到左边的<<字幕颜色滤镜>>编辑栏中,如:Lab: l:0 a:128 b:128 24 | *- 如果字幕颜色有多种,可以用"Ctrl+Enter"在<<字幕颜色滤镜>>编辑栏中添加新的一行颜色信息 25 | 5)在<<识别>>标签页中点击<<开始识别>>(如果你只需要时间轴,这步之后,直接跳到"OCR"标签页,选择<<根据原始视频图片生成只有时间轴的字幕(RGBImages->Sub)>>,生成一个只有时间轴信息的字幕) 26 | 6) 在ILAImages文件夹检查ILA图片: 正常情况下,在ILA图片中的字幕会显示为白色, 如果ILA中的字幕不完整或者不显示,可能是以下情况: 27 | * 使用了强力滤镜 28 | * 字幕没有描边,却使用字幕描边滤镜 29 | * 字幕突然出现或消失 30 | 出现这样的情况最好改变设置或者删除对应的ILA图片 31 | 7)如果不用<<字幕颜色滤镜>>,则需要注意: 32 | 在继续下一步之前,检查字幕描边的颜色是否比字幕文本的颜色更深(大多数情况下是这样的,如果不是,取消选择在<<设置>>标签页中的右边栏中的第一个复选框) 33 | 在大多数情况下,程序能正确地识别与字幕文本相关联的颜色,但某些情况过于复杂,就需要通过其他参数设置来处理; 34 | 8) 如果使用颜色滤镜,ILA图片效果较好,推荐打开<<使用相交亮度区域(ILAImages)获取字符图片 >>以减少无关字符的产生 35 | 9)点击OCR标签页中的<<生成二值化文本图片(RGBImages->TXTImages)>> 36 | 10) 借助其他软件可获得可编辑的字幕文本(FineReader/Subtitle Edit等) 37 | 11) 在OCR标签页中根据需要生成完整字幕 (*.srt or *.ass) 38 | 39 | 相关视频教程: 40 | https://www.bilibili.com/video/BV1U34y187vV/ 41 | https://www.youtube.com/watch?v=Cd36qODmYF8 42 | https://www.youtube.com/watch?v=VHsUfqqAkWY&t=124s 43 | 44 | #--------------------已知的问题-------------------- 45 | 46 | 1) 用OpenCV和FFMPEG打开视频,提取出的时间轴会有细微的差别,在000-001毫秒之间。 47 | 2) 关于字幕中心对齐,如果字幕整体在检测区域的右边,将会被移除。 48 | 3) 字幕丢失。确保字幕长度不小于12帧(0.5S), 可在设置标签页中通过<<字幕持续的最小帧数>>修改。 49 | 4) 在TXTResults文件夹中的所有文本都应是UTF-8格式。 50 | 5) 如果字幕没有描边,不要使用<<字幕描边滤镜>>,会影响ILAImage和ISAImages的生成。 51 | 52 | #--------------------参数设置-------------------- 53 | 54 | 1)为了在<<开始识别>>和<<生成二值化文本图片(RGBImages->TXTImages)>>得到更好的结果 55 | #---------生成RGB图片--------- 56 | *- 导入视频,参数设置好之后,在<<设置>>便签页点击<<测试>>按钮来进行测试,尽量多的选择视频中背景明暗度差异较大的帧来进行测试,比如背景太亮或者太暗 57 | *- 通过用鼠标移动<<视频预览框>>中的垂直和水平分隔线来缩小检测区域 58 | 在某些复杂的情况下,你可以多次运行程序来识别不同区域的字幕,可以解决多行字幕可能出现分割问题 59 | 比如:识别双语字幕、对话在视频下面而注释在视频上面的情况 60 | *- 确认字幕在检测区域里的水平对齐方式:居中/左对齐/右对齐/任意位置,在<<设置>>标签页里的<<文本对齐方式>>中选择对应属性 61 | 中心对齐:默认对齐方式 62 | 任意对齐:当前不如其他几种对齐方式好用 63 | *- 为了减少在<<开始识别>>时出现的:丢轴、错轴,在<<生成二值化文本图片(RGBImages->TXTImages)>>时出现的:文字未被识别、只识别部分的情况, 64 | 对<<限制阈值>>参数的范围[0.25, 0.6]进行调整: 65 | 为了找到最佳的参数值,在<<测试>>时,需要对<<第一次/第二次/第三次过滤>>不同的阶段进行测试, 66 | 直到在右边的<<图片预览框>>中出现完整的白色字幕。 67 | 尽可能尝试那些太亮或太暗的画面,这样画面中大部分与字幕无关的像素将会被移除。 68 | 0.25 - 大多数视频通用,特别是1080p的视频,但是会生成大量无用的图片 69 | 0.5-0.6 - 适用于字幕描边明显的,像白字黑边框的字幕,或者画质低于480p的视频 70 | 0.1 - 适用于字幕没有描边或者字幕颜色比较浅的视频,但是会生成大量无用的图片 71 | *- 使用<<字幕颜色滤镜>>可以极大提高结果的准确性: 72 | 丢轴、错轴的情况会极大的改善,图片二值化后的结果也会更好 73 | *- 字幕的分割也受以下两个因素影响: 74 | vedges_points_line_error = 0.3 75 | ila_points_line_error = 0.3 76 | 0.3意为两个相近字幕的允许差异值为30%,比如:两条不同的字幕都只有十个字,在允许差异值为30%的情况下,其中一条字幕只要有七个字以上与另一条字幕相同,就视为同一条字幕。 77 | 同理,如果允许差异值为50%,则只需要五个字以上与另一条字幕相同就可视为同一条字幕 78 | 值越高,时间轴分割的越少 79 | 值越低,时间轴分割的越多 80 | 一般情况下,不推荐改动,只有在没有连续的字幕的情况下,才去降低参数值。 81 | 82 | #---------二值化图片--------- 83 | *- 检查字幕颜色是否更深,如果不是,取消选择<<设置>>标签页中右边第一项<<字幕深色描边(字幕有描边时使用)>>的复选框 84 | 85 | 大多数情况下,软件能准确识别与字幕有关的颜色,但某些特殊复杂情况,则需要考虑一下参数设置: 86 | *- 二值化过程中部分字符丢失 87 | 与<<缩放图片的限制阈值>>这个参数有关,参数范围[0.1-0.25] 88 | 0.25 - 大多数视频通用,如果有字符丢失,适当调低参数 89 | 0.1-0.15 - 适用于字幕描边不明显的或没有字幕描边的、字幕颜色与背景颜色相近的 90 | 推荐打开<<在二值化图片前根据字幕描边使用交叉亮度区域>>选项,能改善结果 91 | *- 减少二值化过程中多余符号的产生 92 | <<二值化图片多余字符处理(请勿用于象形文字或阿拉伯语)>>默认打开,但是可能会移除部分正确的字符 93 | 94 | *- 其他能帮助二值化图片的选项 95 | 识别的语言不是符号、阿拉伯语、手写字幕 96 | 字符是完整的,有着稳定的亮度 97 | 使用<<字幕描边滤镜>> 98 | 如果使用了颜色滤镜,以及提取的ILAImages质量很好,推荐打开<<使用相交亮度区域(ILAImages)获取字符图片>>选项,可以减少多余符号的生成 99 | 打<<移除不规则的字(请勿用于阿拉伯语和手写文字)>>选项,减少多余字符的产生 100 | 101 | 2) 颜色滤镜参数详解 102 | *- 常用颜色滤镜参数范围 103 | Lab: l:180-255 a:108-148 b:108-148 (大多数视频通用) 104 | Lab: l:200-255 a:118-138 b:118-138 105 | Lab: l:220-255 a:118-138 b:118-138 (强力颜色滤镜,视频质量很好的情况下使用,字幕亮度不稳定不推荐使用) 106 | 107 | 参数格式: 108 | Lab: l:l_val a:a_val b:b_lab_val 109 | Lab: l:min_l_val-max_l_val a:min_a_val-max_a_val b:min_b_lab_val-max_b_lab_val 110 | RGB: r:min_r_val-max_r_val g:min_g_val-max_g_val b:min_b_val-max_b_val 111 | RGB: r:r_val g:g_val b:b_val L:l_val 112 | RGB: r:r_val g:g_val b:b_val L:min_l_val-max_l_val 113 | 114 | *- 描边的颜色参数范围同上,除非描边很明显,否则<<字幕描边滤镜>>选项不建议使用强力滤镜 115 | *- 在<<视频预览框>>中,按"T"可全屏查看设置颜色滤镜后效果 116 | 可通过左右方向键和空格键来查看不同帧 117 | *- 字幕颜色是红色的 118 | *- 描边颜色是绿色的 119 | *- 字幕和描边重合部分是黄色的 120 | 121 | 同样: 122 | 按"U"可全屏查看原始视频帧 123 | 按"Y"查看原视频中剥离出来的字幕的颜色,比如:字幕是黄色的,屏幕上应该就只出现黄色的字幕 124 | 按"I"查看原视频中剥离出来的描边的颜色 125 | *- 如果使用<<字幕描边滤镜>>或ILAImages图像质量不错,推荐打开<<使用相交亮度区域(ILAImages)获取字符图片>>,可减少无效字符的出现 126 | 127 | 3) 二值化质量不高的视频 128 | *- 字幕亮度不稳定的情况 129 | 打开<<字幕深色描边(字幕有描边时使用)>>,人工设定<<允许的最低亮度(仅在灰度扩展选项下生效)>>,最低亮度的值 130 | 如果使用颜色滤镜,建议把最低亮度的值设成跟颜色滤镜的"min_l_val"相等 131 | 参数范围:[min("允许的最低亮度", 自动检测的最低亮度), 自动检测的最高亮度] 132 | 133 | <<伽马(Video Gamma)>>和<<对比度(Video Contrast)>>对结果也有帮助 134 | 某些情况下,设置<<伽马(Video Gamma)>> == 0.7、<<允许的最低亮度(仅在灰度扩展选项下生效)>> == 100、打开<<灰度扩展(在字幕亮度不稳定的时候使用)>>,会很有帮助 135 | 具体情况中,需要自己不断测试才能得到最优的参数值 136 | 137 | *- 借助第三方图片增强软件 138 | 使用"Topaz Gigapixel AI": https://topazlabs.com/gigapixel-ai/,对提取的RGB图片进行增强 139 | 建议按默认的两倍放大增强,由于图片的名称就是字幕的时间轴,增强后的图片名称应与原来的一致 140 | 141 | 4) 二值化没有描边的字幕 142 | 这种情况下,某些字符的分离会变得很困难 143 | 可以打开<<在二值化图片前根据字幕描边使用交叉亮度区域 >>选项,会很有帮助 144 | 正确设置合适的字幕颜色滤镜 145 | 并且,在背景是动态的情况下,ILA images会很有帮助 146 | 以下列举的参数对背景分离也很有帮助: 147 | "Min Sum Color Difference": min_sum_color_diff = 0 148 | "Moderate Threshold": moderate_threshold = 0.1 149 | "Moderate Threshold For Scaled Image": moderate_threshold_for_scaled_image = 0.1 150 | "Use ILAImages for getting TXT symbols areas" - Turn Off: use_ILA_images_for_getting_txt_symbols_areas = 0 151 | 152 | 5) 一条字幕有多种颜色 153 | 用"Ctrl+Enter"在<<字幕颜色滤镜>>编辑栏中添加多条颜色参数后,打开<<合并到单个集群(可用于单行中有多种颜色的情况)>>选项 154 | 155 | 6) 提高软件二值化过程中的运行性能 156 | 默认的参数为: 157 | "CPU kmeans initial loop iterations" == 20 158 | "CPU kmeans loop iterations" = 30 159 | 以上参数适应于各种情况,特别是在字幕没有良好的描边的情况下,当字幕有明显的描边的时候,两个指标的参数都可以设为10。 160 | 161 | #--------------------OCR相关-------------------- 162 | 注意:创建的所有文本类型都应为UTF-8格式。 163 | 164 | 1) FineReader与Subtitle Edit相关教程 165 | https://www.bilibili.com/video/BV1vp4y1i7Ek/?vd_source=1fba6762e7b2d878744d3b6ede0a9b26 166 | 167 | 2) Google Drive等在线OCR相关教程 168 | 1.通过"OCR"选项卡中的"拼合图片(TXT/RGBImages->ImagesJoined)"按钮合并TXT/RGBImages,生成拼合图片后,如果识别结果文件夹(TXTResults)内不存在"join_txt_results.txt"文件,将会自动创建。 169 | 在"OCR"选项卡页面左侧的设置中,可更改选项: 170 | *- 拼合RGB图片或者拼合二值化图片。 171 | *- 使用二值化图片的数据拼合RGB图片(最优选择),如果勾选,它只会拼合二值化时识别到文字的对应图片。 172 | *- 拼图最大数量:将TXT/RGBImages拼合成一个图片时使用到的最大数量,在某些情况下,"缩放倍数 (根据原始RGB图像缩放)"== 1时最大数量可以填160,但根据OCR使用经验,填50比填100更准确。 173 | *- 如果分隔符字号为"-1",会根据平均图像高度(以及在TXTImages中的行数)自动生成最佳的分隔符字号,你也可以手动设置范围(1-80)。 174 | *- "缩放倍数 ":根据原始RGB图像缩放。 175 | *- 拼合图片的分隔符,支持宏定义:[sub_id], [begin_time], [end_time]。 176 | [重点]但想准确生成字幕,目前仅支持[sub_id]更改格式 177 | 178 | 注意:当程序在"TXTResults/join_txt_results.txt"中搜索相关字幕数据时,他会在末尾添加额外的[sub_id] 179 | [重点]一般不需要更改,如果OCR无法正确识别分隔符时,可以尝试更改。 180 | 181 | 2.将ImagesJoined文件夹中合并的图片上传到Google云盘中的某个目录。 182 | 183 | 3.鼠标单击每个合并的图片→打开方式→谷歌文档(它会自动OCR并生成文档) 184 | 注意:如果OCR失败并且文档内容为空,你可以尝试修改: 185 | *- "缩放倍数 (根据原始RGB图像缩放)"的数值,大多数情况下,谷歌文档对不缩放的图像OCR效果更好。 186 | 187 | 4.打开每个生成的文档,并将所有文本复制到"TXTResults/join_txt_results.txt"文件中,并以UTF8的格式保存。 188 | 注意:"\n"(换行)无关紧要,只需要依次将每个图片的识别结果复制到"TXTResults/join_txt_results.txt"内即可 189 | 190 | 5.通过单击OCR选项卡中的"根据文本生成字幕"按钮,根据"TXTResults/join_txt_results.txt"文件生成字幕(*.srt or *.ass) 191 | 192 | 3)百度OCR相关教程(推荐) 193 | https://www.bilibili.com/video/BV1U34y187vV/ 194 | 195 | #--------------------后记-------------------- 196 | 翻译:豆瓣@我在成都养熊猫 197 | 相较于英文版教程,进行了部分筛减和补充,完整版请查看英文版本 198 | 欢迎加入硬字幕提取交流群:1161766056,教程中提及的相关软件可进群下载 199 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/BitmapButton.cpp: -------------------------------------------------------------------------------- 1 | //BitmapButton.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include "BitmapButton.h" 19 | #include 20 | 21 | BEGIN_EVENT_TABLE(CBitmapButton, wxWindow) 22 | EVT_PAINT(CBitmapButton::OnPaint) 23 | EVT_LEFT_DOWN(CBitmapButton::OnLButtonDown) 24 | EVT_LEFT_UP(CBitmapButton::OnLButtonUp) 25 | EVT_ENTER_WINDOW(CBitmapButton::OnMouseEnter) 26 | EVT_LEAVE_WINDOW(CBitmapButton::OnMouseLeave) 27 | EVT_MOTION(CBitmapButton::OnMouseMove) 28 | EVT_MOUSE_CAPTURE_LOST(CBitmapButton::OnMouseCaptureLost) 29 | END_EVENT_TABLE() 30 | 31 | CBitmapButton::CBitmapButton(wxWindow* parent, 32 | wxWindowID id, 33 | const wxImage& image, 34 | const wxImage& image_focused, 35 | const wxImage& image_selected, 36 | const wxPoint& pos, 37 | const wxSize& size) : wxWindow(parent, id, pos, size, wxCLIP_CHILDREN | wxWANTS_CHARS) 38 | { 39 | m_parent = parent; 40 | m_bDown = false; 41 | m_image = image; 42 | m_image_focused = image_focused; 43 | m_image_selected = image_selected; 44 | m_bImagesDefined = true; 45 | } 46 | 47 | CBitmapButton::CBitmapButton(wxWindow* parent, 48 | wxWindowID id, 49 | const wxImage& image, 50 | const wxImage& image_selected, 51 | const wxPoint& pos, 52 | const wxSize& size) : CBitmapButton(parent, id, image, image, image_selected, pos, size) 53 | { 54 | } 55 | 56 | CBitmapButton::CBitmapButton(wxWindow* parent, 57 | wxWindowID id, 58 | const wxPoint& pos, 59 | const wxSize& size) : wxWindow(parent, id, pos, size, wxCLIP_CHILDREN | wxWANTS_CHARS) 60 | { 61 | m_parent = parent; 62 | m_bDown = false; 63 | m_bImagesDefined = false; 64 | } 65 | 66 | void CBitmapButton::SetBitmaps(const wxImage& image, 67 | const wxImage& image_focused, 68 | const wxImage& image_selected) 69 | { 70 | m_image = image; 71 | m_image_focused = image_focused; 72 | m_image_selected = image_selected; 73 | m_bImagesDefined = true; 74 | this->Refresh(true); 75 | } 76 | 77 | wxSize CBitmapButton::GetOptimalSize(int req_w, int req_h) 78 | { 79 | wxSize cur_size = this->GetSize(); 80 | wxSize cur_client_size = this->GetClientSize(); 81 | wxSize image_size = m_image.GetSize(); 82 | wxSize opt_size; 83 | 84 | if (req_h > 0) 85 | { 86 | opt_size.x = (((req_h - (cur_size.y - cur_client_size.y)) * image_size.x) / image_size.y) + (cur_size.x - cur_client_size.x); 87 | opt_size.y = req_h; 88 | } 89 | else if (req_w > 0) 90 | { 91 | opt_size.x = req_w; 92 | opt_size.y = (((req_w - (cur_size.x - cur_client_size.x)) * image_size.y) / image_size.x) + (cur_size.y - cur_client_size.y); 93 | } 94 | else 95 | { 96 | opt_size.x = image_size.x + (cur_size.x - cur_client_size.x); 97 | opt_size.y = image_size.y + (cur_size.y - cur_client_size.y); 98 | } 99 | 100 | return opt_size; 101 | } 102 | 103 | void CBitmapButton::OnLButtonDown( wxMouseEvent& event ) 104 | { 105 | m_bDown = true; 106 | this->CaptureMouse(); 107 | this->Refresh(true); 108 | 109 | wxCommandEvent bnev(wxEVT_BUTTON, this->GetId()); 110 | wxPostEvent(m_parent, bnev); 111 | } 112 | 113 | void CBitmapButton::OnLButtonUp( wxMouseEvent& event ) 114 | { 115 | if (m_bDown == true) 116 | { 117 | m_bDown = false; 118 | this->ReleaseMouse(); 119 | this->Refresh(true); 120 | } 121 | } 122 | 123 | void CBitmapButton::OnMouseEnter(wxMouseEvent& event) 124 | { 125 | this->Refresh(true); 126 | } 127 | 128 | void CBitmapButton::OnMouseLeave(wxMouseEvent& event) 129 | { 130 | this->Refresh(true); 131 | } 132 | 133 | void CBitmapButton::OnMouseMove(wxMouseEvent& event) 134 | { 135 | if (m_ShownBitmap != ShownBitmap::Focused) 136 | { 137 | this->Refresh(true); 138 | } 139 | } 140 | 141 | void CBitmapButton::OnMouseCaptureLost(wxMouseCaptureLostEvent& event) 142 | { 143 | if (m_bDown == true) 144 | { 145 | m_bDown = false; 146 | this->Refresh(true); 147 | } 148 | } 149 | 150 | void CBitmapButton::OnPaint(wxPaintEvent& event) 151 | { 152 | if (m_bImagesDefined) 153 | { 154 | wxPaintDC dc(this); 155 | int cw, ch; 156 | this->GetClientSize(&cw, &ch); 157 | 158 | if (m_bDown) 159 | { 160 | m_ShownBitmap = ShownBitmap::Selected; 161 | dc.DrawBitmap(wxBitmap(m_image_selected.Scale(cw, ch, wxIMAGE_QUALITY_BILINEAR)), 0, 0); 162 | } 163 | else 164 | { 165 | wxPoint clao = GetClientAreaOrigin(); 166 | wxPoint mp = wxGetMousePosition() - GetScreenPosition() - clao; 167 | int w, h; 168 | this->GetClientSize(&w, &h); 169 | 170 | if ((mp.x >= 0) && 171 | (mp.x < w) && 172 | (mp.y >= 0) && 173 | (mp.y < h)) 174 | { 175 | m_ShownBitmap = ShownBitmap::Focused; 176 | dc.DrawBitmap(wxBitmap(m_image_focused.Scale(cw, ch, wxIMAGE_QUALITY_BILINEAR)), 0, 0); 177 | } 178 | else 179 | { 180 | m_ShownBitmap = ShownBitmap::Default; 181 | dc.DrawBitmap(wxBitmap(m_image.Scale(cw, ch, wxIMAGE_QUALITY_BILINEAR)), 0, 0); 182 | } 183 | } 184 | } 185 | } -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/BitmapButton.h: -------------------------------------------------------------------------------- 1 | //BitmapButton.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | 21 | class CBitmapButton : public wxWindow 22 | { 23 | enum ShownBitmap { Default, Focused, Selected }; 24 | 25 | public: 26 | CBitmapButton(wxWindow* parent, 27 | wxWindowID id, 28 | const wxImage& image, 29 | const wxImage& image_focused, 30 | const wxImage& image_selected, 31 | const wxPoint& pos = wxDefaultPosition, 32 | const wxSize& size = wxDefaultSize); 33 | 34 | CBitmapButton(wxWindow* parent, 35 | wxWindowID id, 36 | const wxImage& image, 37 | const wxImage& image_selected, 38 | const wxPoint& pos = wxDefaultPosition, 39 | const wxSize& size = wxDefaultSize); 40 | 41 | CBitmapButton(wxWindow* parent, 42 | wxWindowID id, 43 | const wxPoint& pos = wxDefaultPosition, 44 | const wxSize& size = wxDefaultSize); 45 | 46 | void OnLButtonDown( wxMouseEvent& event ); 47 | void OnLButtonUp( wxMouseEvent& event ); 48 | void OnMouseEnter(wxMouseEvent& event); 49 | void OnMouseLeave(wxMouseEvent& event); 50 | void OnMouseMove(wxMouseEvent& event); 51 | void OnMouseCaptureLost(wxMouseCaptureLostEvent& event); 52 | void OnPaint(wxPaintEvent& event); 53 | void SetBitmaps(const wxImage& image, 54 | const wxImage& image_focused, 55 | const wxImage& image_selected); 56 | wxSize GetOptimalSize(int req_w = 0, int req_h = 0); 57 | 58 | wxImage m_image; 59 | wxImage m_image_focused; 60 | wxImage m_image_selected; 61 | 62 | private: 63 | ShownBitmap m_ShownBitmap = ShownBitmap::Default; 64 | bool m_bDown; 65 | bool m_bImagesDefined; 66 | wxWindow* m_parent; 67 | 68 | DECLARE_EVENT_TABLE() 69 | }; 70 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/Button.cpp: -------------------------------------------------------------------------------- 1 | //Button.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include "Button.h" 19 | #include 20 | #include 21 | 22 | BEGIN_EVENT_TABLE(CButton, CBitmapButton) 23 | EVT_SIZE(CButton::OnSize) 24 | END_EVENT_TABLE() 25 | 26 | CButton::CButton(wxWindow* parent, 27 | wxWindowID id, 28 | wxColour& button_color, 29 | wxColour& button_color_focused, 30 | wxColour& button_color_selected, 31 | wxColour& buttons_border_colour, 32 | const wxString& label, 33 | const wxPoint& pos, 34 | const wxSize& size) : CBitmapButton(parent, id, pos, size) 35 | { 36 | m_pParent = parent; 37 | m_pFont = NULL; 38 | m_p_text_colour = NULL; 39 | m_p_label = &label; 40 | m_p_button_color = &button_color; 41 | m_p_button_color_focused = &button_color_focused; 42 | m_p_button_color_selected = &button_color_selected; 43 | m_p_buttons_border_colour = &buttons_border_colour; 44 | 45 | wxSizeEvent event; 46 | this->OnSize(event); 47 | } 48 | 49 | void CButton::FillButtonBitmap(wxBitmap& bmp, wxColour parent_colour, wxColour button_colour, wxColour button_border_colour) 50 | { 51 | int w, h; 52 | int cr = 5; 53 | int bw = 1; 54 | 55 | w = bmp.GetWidth(); 56 | h = bmp.GetHeight(); 57 | 58 | wxMemoryDC dc; 59 | dc.SelectObject(bmp); 60 | 61 | dc.SetPen(wxPen(parent_colour)); 62 | dc.SetBrush(wxBrush(parent_colour)); 63 | dc.DrawRectangle(0, 0, w, h); 64 | 65 | dc.SetPen(wxPen(button_border_colour, bw)); 66 | dc.SetBrush(wxBrush(button_colour)); 67 | dc.DrawCircle(cr, cr, cr); 68 | dc.DrawCircle(w - cr - 1, cr, cr); 69 | dc.DrawCircle(cr, h - cr - 1, cr); 70 | dc.DrawCircle(w - cr - 1, h - cr - 1, cr); 71 | 72 | dc.SetPen(wxPen(button_colour)); 73 | dc.DrawRectangle(cr, 0, w - (2 * cr), h); 74 | dc.DrawRectangle(0, cr, w, h - (2 * cr)); 75 | 76 | dc.SetPen(wxPen(button_border_colour, bw)); 77 | dc.DrawLine(cr, 0, w - cr, 0); 78 | dc.DrawLine(cr, h - 1, w - cr, h - 1); 79 | dc.DrawLine(0, cr, 0, h - cr); 80 | dc.DrawLine(w - 1, cr, w - 1, h - cr); 81 | 82 | if (m_p_label->size() > 0) 83 | { 84 | if (m_pFont) dc.SetFont(*m_pFont); 85 | if (m_p_text_colour) dc.SetTextForeground(*m_p_text_colour); 86 | wxSize ts = dc.GetMultiLineTextExtent(*m_p_label); 87 | 88 | dc.DrawText(*m_p_label, (w - ts.x) / 2, (h - ts.y) / 2); 89 | } 90 | } 91 | 92 | void CButton::OnSize(wxSizeEvent& event) 93 | { 94 | int w, h; 95 | 96 | this->GetClientSize(&w, &h); 97 | 98 | if ((w > 0) && (h > 0)) 99 | { 100 | wxBitmap bmp(w, h), bmp_focused(w, h), bmp_selected(w, h); 101 | FillButtonBitmap(bmp, m_pParent->GetBackgroundColour(), *m_p_button_color, *m_p_buttons_border_colour); 102 | FillButtonBitmap(bmp_focused, m_pParent->GetBackgroundColour(), *m_p_button_color_focused, *m_p_buttons_border_colour); 103 | FillButtonBitmap(bmp_selected, m_pParent->GetBackgroundColour(), *m_p_button_color_selected, *m_p_buttons_border_colour); 104 | SetBitmaps(bmp.ConvertToImage(), bmp_focused.ConvertToImage(), bmp_selected.ConvertToImage()); 105 | 106 | this->Refresh(true); 107 | } 108 | 109 | event.Skip(); 110 | } 111 | 112 | void CButton::SetLabel(const wxString& label) 113 | { 114 | m_p_label = &label; 115 | RefreshData(); 116 | } 117 | 118 | void CButton::SetFont(wxFont& font) 119 | { 120 | m_pFont = &font; 121 | RefreshData(); 122 | } 123 | 124 | void CButton::SetTextColour(wxColour& colour) 125 | { 126 | m_p_text_colour = &colour; 127 | wxSizeEvent event; 128 | this->OnSize(event); 129 | } 130 | 131 | void CButton::SetMinSize(wxSize& size) 132 | { 133 | m_min_size = size; 134 | } 135 | 136 | void CButton::RefreshData() 137 | { 138 | wxSizer* pSizer = GetContainingSizer(); 139 | if (pSizer) 140 | { 141 | wxMemoryDC dc; 142 | if (m_pFont) dc.SetFont(*m_pFont); 143 | wxSize best_size = dc.GetMultiLineTextExtent(*m_p_label); 144 | wxSize cur_size = this->GetSize(); 145 | wxSize cur_client_size = this->GetClientSize(); 146 | wxSize opt_size; 147 | best_size.x += cur_size.x - cur_client_size.x + 20; 148 | best_size.y += cur_size.y - cur_client_size.y + 10; 149 | 150 | opt_size.x = std::max(best_size.x, m_min_size.x); 151 | opt_size.y = std::max(best_size.y, m_min_size.y); 152 | 153 | if (opt_size != cur_size) 154 | { 155 | bool res = pSizer->SetItemMinSize(this, opt_size); 156 | pSizer->Layout(); 157 | } 158 | } 159 | 160 | wxSizeEvent event; 161 | this->OnSize(event); 162 | } 163 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/Button.h: -------------------------------------------------------------------------------- 1 | //Button.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include "Control.h" 20 | #include "BitmapButton.h" 21 | 22 | class CButton : public CBitmapButton, public CControl 23 | { 24 | public: 25 | CButton(wxWindow* parent, 26 | wxWindowID id, 27 | wxColour& button_color, 28 | wxColour& button_color_focused, 29 | wxColour& button_color_selected, 30 | wxColour& buttons_border_colour, 31 | const wxString& label, 32 | const wxPoint& pos = wxDefaultPosition, 33 | const wxSize& size = wxDefaultSize); 34 | 35 | CButton(wxWindow* parent, 36 | wxWindowID id, 37 | wxColour& button_color, 38 | wxColour& button_color_focused, 39 | wxColour& button_color_selected, 40 | wxColour& buttons_border_colour, 41 | const wxString&& label, 42 | const wxPoint& pos = wxDefaultPosition, 43 | const wxSize& size = wxDefaultSize) = delete; 44 | 45 | void SetLabel(const wxString& label); 46 | void SetLabel(const wxString&& label) = delete; 47 | void RefreshData(); 48 | void SetFont(wxFont& font); 49 | void SetTextColour(wxColour& colour); 50 | void SetMinSize(wxSize& size); 51 | 52 | void OnSize(wxSizeEvent& event); 53 | 54 | private: 55 | wxSize m_min_size; 56 | wxWindow* m_pParent; 57 | CBitmapButton* m_pButton; 58 | wxFont* m_pFont; 59 | wxColour* m_p_button_color; 60 | wxColour* m_p_button_color_focused; 61 | wxColour* m_p_button_color_selected; 62 | wxColour* m_p_buttons_border_colour; 63 | wxColour* m_p_text_colour; 64 | const wxString* m_p_label; 65 | 66 | void FillButtonBitmap(wxBitmap& bmp, wxColour parent_colour, wxColour button_colour, wxColour button_border_colour); 67 | 68 | DECLARE_EVENT_TABLE() 69 | }; 70 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB VideoSubFinderWXW_src 2 | "*.h" 3 | "*.cpp" 4 | ) 5 | 6 | if (WIN32) 7 | add_executable(VideoSubFinderWXW WIN32 ${VideoSubFinderWXW_src} VideoSubFinderWXW.rc) 8 | else() 9 | add_executable(VideoSubFinderWXW ${VideoSubFinderWXW_src}) 10 | endif (WIN32) 11 | 12 | target_compile_features(VideoSubFinderWXW PUBLIC cxx_std_17) 13 | 14 | target_include_directories(VideoSubFinderWXW PUBLIC 15 | ${wxWidgets_INCLUDE_DIRS} 16 | ${OpenCV_INCLUDE_DIRS} 17 | "../../Components/Include" 18 | "../../Components/IPAlgorithms" 19 | "../../Components/OCVVideo" 20 | "../../Components/FFMPEGVideo" 21 | ) 22 | 23 | if (WIN32) 24 | target_link_directories(VideoSubFinderWXW PUBLIC 25 | ${VideoSubFinderWXW_LINK_DIRS} 26 | ) 27 | 28 | target_link_libraries(VideoSubFinderWXW PUBLIC 29 | IPAlgorithms 30 | OCVVideo 31 | FFMPEGVideo 32 | ${CUDAKernels_LIB} 33 | wxmsw32u_aui.lib 34 | wxmsw32u_media.lib 35 | wxmsw32u_core.lib 36 | wxmsw32u_adv.lib 37 | wxbase32u.lib 38 | wxtiff.lib 39 | wxjpeg.lib 40 | wxpng.lib 41 | wxzlib.lib 42 | wxregexu.lib 43 | wxexpat.lib 44 | winmm.lib 45 | comctl32.lib 46 | rpcrt4.lib 47 | wsock32.lib 48 | odbc32.lib 49 | vfw32.lib 50 | avdevice.lib 51 | avformat.lib 52 | avfilter.lib 53 | avcodec.lib 54 | swresample.lib 55 | swscale.lib 56 | avutil.lib 57 | ${OpenCV_LIBS} 58 | ) 59 | else() 60 | target_compile_definitions(VideoSubFinderWXW PUBLIC 61 | ${wxWidgets_DEFINITIONS} 62 | $<$:${wxWidgets_DEFINITIONS_DEBUG}>) 63 | target_compile_options(VideoSubFinderWXW PRIVATE ${wxWidgets_CXX_FLAGS}) 64 | 65 | target_link_directories(VideoSubFinderWXW PUBLIC 66 | ${wxWidgets_LIBRARY_DIRS} 67 | ${CUDA_LINK_DIRS} 68 | ) 69 | 70 | target_link_libraries(VideoSubFinderWXW PUBLIC 71 | IPAlgorithms 72 | OCVVideo 73 | FFMPEGVideo 74 | ${CUDAKernels_LIB} 75 | ${wxWidgets_LIBRARIES} 76 | ${OpenCV_LIBS} 77 | avcodec 78 | avformat 79 | avutil 80 | swscale 81 | avfilter 82 | tbb 83 | X11 84 | ) 85 | endif (WIN32) 86 | 87 | 88 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/CheckBox.cpp: -------------------------------------------------------------------------------- 1 | //CheckBox.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include "CheckBox.h" 19 | #include 20 | #include 21 | 22 | BEGIN_EVENT_TABLE(CCheckBox, wxCheckBox) 23 | EVT_SIZE(CCheckBox::OnSize) 24 | END_EVENT_TABLE() 25 | 26 | CCheckBox::CCheckBox(wxWindow* parent, 27 | wxWindowID id, 28 | bool* p_val, 29 | const wxString& label, 30 | const wxPoint& pos, 31 | const wxSize& size, 32 | long check_box_style, 33 | long text_style, 34 | long panel_style) : wxPanel(parent, id, pos, size, panel_style, wxT("")) 35 | { 36 | m_pParent = parent; 37 | m_p_val = p_val; 38 | m_p_label = &label; 39 | 40 | m_text_style = text_style; 41 | m_check_box_style = check_box_style; 42 | 43 | m_pST = new wxStaticText(this, wxID_ANY, label, wxDefaultPosition, wxDefaultSize, m_text_style, wxStaticTextNameStr); 44 | m_pCB = new wxCheckBox(this, id, wxT(""), wxDefaultPosition, wxDefaultSize, ((m_check_box_style ^ wxALIGN_RIGHT) ^ wxALIGN_LEFT)); 45 | 46 | m_pCB->SetValue(*m_p_val); 47 | 48 | m_pCB->Bind(wxEVT_CHECKBOX, &CCheckBox::OnCheckBoxEvent, this); 49 | } 50 | 51 | void CCheckBox::SetFont(wxFont& font) 52 | { 53 | m_pFont = &font; 54 | if (m_pFont) m_pST->SetFont(*m_pFont); 55 | 56 | wxSizeEvent event; 57 | OnSize(event); 58 | } 59 | 60 | void CCheckBox::SetTextColour(wxColour& colour) 61 | { 62 | m_pTextColour = &colour; 63 | m_pST->SetForegroundColour(*m_pTextColour); 64 | } 65 | 66 | void CCheckBox::SetBackgroundColour(wxColour& colour) 67 | { 68 | m_pBackgroundColour = &colour; 69 | wxPanel::SetBackgroundColour(*m_pBackgroundColour); 70 | m_pST->SetBackgroundColour(*m_pBackgroundColour); 71 | } 72 | 73 | void CCheckBox::SetLabel(const wxString& label) 74 | { 75 | m_p_label = &label; 76 | m_pST->SetLabel(*m_p_label); 77 | wxSizeEvent event; 78 | OnSize(event); 79 | } 80 | 81 | void CCheckBox::SetMinSize(wxSize& size) 82 | { 83 | m_min_size = size; 84 | } 85 | 86 | void CCheckBox::RefreshData() 87 | { 88 | m_pST->SetLabel(*m_p_label); 89 | m_pCB->SetValue(*m_p_val); 90 | if (m_pFont) m_pST->SetFont(*m_pFont); 91 | if (m_pTextColour) m_pST->SetForegroundColour(*m_pTextColour); 92 | if (m_pBackgroundColour) 93 | { 94 | wxPanel::SetBackgroundColour(*m_pBackgroundColour); 95 | m_pST->SetBackgroundColour(*m_pBackgroundColour); 96 | } 97 | 98 | wxSizer* pSizer = GetContainingSizer(); 99 | if (pSizer) 100 | { 101 | wxMemoryDC dc; 102 | if (m_pFont) dc.SetFont(*m_pFont); 103 | wxSize best_size = dc.GetMultiLineTextExtent(*m_p_label); 104 | wxSize cur_size = this->GetSize(); 105 | wxSize cur_client_size = this->GetClientSize(); 106 | wxSize cb_size = m_pCB->GetSize(); 107 | wxSize opt_size; 108 | best_size.x += cur_size.x - cur_client_size.x + 6 + (m_cb_offset * 2) + cb_size.x; 109 | best_size.y += cur_size.y - cur_client_size.y + 6; 110 | 111 | opt_size.x = std::max(best_size.x, m_min_size.x); 112 | opt_size.y = std::max({best_size.y, m_min_size.y, cb_size.y}); 113 | 114 | if (opt_size != cur_size) 115 | { 116 | pSizer->SetItemMinSize(this, opt_size); 117 | pSizer->Layout(); 118 | } 119 | } 120 | 121 | wxSizeEvent event; 122 | OnSize(event); 123 | } 124 | 125 | void CCheckBox::OnCheckBoxEvent(wxCommandEvent& evt) 126 | { 127 | if (evt.IsChecked()) 128 | { 129 | *m_p_val = true; 130 | } 131 | else 132 | { 133 | *m_p_val = false; 134 | } 135 | 136 | evt.Skip(); 137 | } 138 | 139 | void CCheckBox::OnSize(wxSizeEvent& event) 140 | { 141 | int w, h, stw, sth, cbw, cbh, x, y, stp_beg_x, stp_end_x, stp_w, cb_x, cb_y = m_cb_offset; 142 | 143 | this->GetClientSize(&w, &h); 144 | 145 | if ((w > 0) && (h > 0)) 146 | { 147 | { 148 | wxMemoryDC dc; 149 | if (m_pFont) dc.SetFont(*m_pFont); 150 | wxSize text_size = dc.GetMultiLineTextExtent(*m_p_label); 151 | wxSize st_cur_size = m_pST->GetSize(); 152 | wxSize st_cur_client_size = m_pST->GetClientSize(); 153 | stw = text_size.x + st_cur_size.x - st_cur_client_size.x; 154 | sth = text_size.y + st_cur_size.y - st_cur_client_size.y; 155 | } 156 | 157 | m_pCB->GetSize(&cbw, &cbh); 158 | 159 | if (m_check_box_style & wxALIGN_RIGHT) 160 | { 161 | stp_beg_x = 0; 162 | stp_end_x = w - cbw - 1 - (m_cb_offset * 2); 163 | cb_x = stp_end_x + 1 + m_cb_offset; 164 | } 165 | else // left aligned 166 | { 167 | stp_beg_x = cbw + (m_cb_offset * 2) + 1; // add +1 due to text become too close to check box 168 | stp_end_x = w - 1; 169 | cb_x = m_cb_offset; 170 | } 171 | 172 | stp_w = stp_end_x - stp_beg_x + 1 - 1; // add -1 due to text become too close to check box 173 | 174 | if (m_check_box_style & wxALIGN_CENTER_VERTICAL) 175 | { 176 | cb_y = (h - sth) / 2; 177 | } 178 | 179 | if (m_text_style & wxALIGN_CENTER_HORIZONTAL) 180 | { 181 | x = stp_beg_x + (stp_w - stw) / 2; 182 | } 183 | else if (m_text_style & wxALIGN_RIGHT) 184 | { 185 | x = stp_beg_x + stp_w - stw; 186 | } 187 | else 188 | { 189 | x = stp_beg_x; 190 | } 191 | 192 | if (m_text_style & wxALIGN_CENTER_VERTICAL) 193 | { 194 | y = (h - sth) / 2; 195 | } 196 | else if (m_text_style & wxALIGN_BOTTOM) 197 | { 198 | y = h - sth; 199 | } 200 | else 201 | { 202 | y = 0; 203 | } 204 | 205 | m_pST->SetSize(x, y, stw, sth); 206 | m_pCB->SetPosition(wxPoint(cb_x, cb_y)); 207 | } 208 | 209 | event.Skip(); 210 | } 211 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/CheckBox.h: -------------------------------------------------------------------------------- 1 | //CheckBox.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include 21 | #include "Control.h" 22 | 23 | class CCheckBox : public wxPanel, public CControl 24 | { 25 | public: 26 | bool* m_p_val; 27 | 28 | CCheckBox(wxWindow* parent, 29 | wxWindowID id, 30 | bool* p_val, 31 | const wxString& label, 32 | const wxPoint& pos = wxDefaultPosition, 33 | const wxSize& size = wxDefaultSize, 34 | long check_box_style = wxALIGN_RIGHT | wxCHK_2STATE | wxALIGN_CENTER_VERTICAL, 35 | long text_style = wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 36 | long panel_style = wxTAB_TRAVERSAL | wxBORDER); 37 | 38 | CCheckBox(wxWindow* parent, 39 | wxWindowID id, 40 | bool* p_val, 41 | const wxString&& label, 42 | const wxPoint& pos = wxDefaultPosition, 43 | const wxSize& size = wxDefaultSize, 44 | long check_box_style = wxALIGN_RIGHT | wxCHK_2STATE | wxALIGN_CENTER_VERTICAL, 45 | long text_style = wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 46 | long panel_style = wxTAB_TRAVERSAL | wxBORDER) = delete; 47 | 48 | void OnSize(wxSizeEvent& event); 49 | void OnCheckBoxEvent(wxCommandEvent& evt); 50 | void SetFont(wxFont& font); 51 | void SetTextColour(wxColour& colour); 52 | void SetLabel(const wxString& label); 53 | void SetBackgroundColour(wxColour& colour); 54 | void SetMinSize(wxSize& size); 55 | void RefreshData(); 56 | 57 | wxWindow* m_pParent; 58 | wxStaticText* m_pST; 59 | wxCheckBox* m_pCB; 60 | long m_text_style; 61 | long m_check_box_style; 62 | int m_cb_offset = 2; 63 | 64 | private: 65 | wxSize m_min_size; 66 | wxFont* m_pFont = NULL; 67 | wxColour* m_pTextColour = NULL; 68 | wxColour* m_pBackgroundColour = NULL; 69 | const wxString* m_p_label; 70 | DECLARE_EVENT_TABLE() 71 | }; 72 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/Choice.cpp: -------------------------------------------------------------------------------- 1 | //Choice.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #include "Choice.h" 18 | #include 19 | #include 20 | 21 | BEGIN_EVENT_TABLE(CChoice, wxChoice) 22 | EVT_CHOICE(wxID_ANY, CChoice::OnChoice) 23 | END_EVENT_TABLE() 24 | 25 | CChoice::CChoice(wxWindow* parent, 26 | wxArrayString& vals, 27 | wxString* p_str_selection, 28 | wxWindowID id, 29 | const wxPoint& pos, 30 | const wxSize& size) 31 | :wxChoice(parent, id, pos, size, vals) 32 | { 33 | m_pParent = parent; 34 | m_p_str_selection = p_str_selection; 35 | m_vals = vals; 36 | 37 | if (!(this->SetStringSelection(*m_p_str_selection))) 38 | { 39 | this->Select(0); 40 | *m_p_str_selection = this->GetStringSelection(); 41 | } 42 | 43 | wxSize def_best_size = wxChoice::GetBestSize(); 44 | wxSize opt_size = GetOptimalSize(); 45 | 46 | m_vgap = def_best_size.y - opt_size.y; 47 | m_hgap = def_best_size.x - opt_size.x; 48 | } 49 | 50 | CChoice::CChoice(wxWindow* parent, 51 | wxArrayString& vals, 52 | int* p_int_selection, 53 | wxWindowID id, 54 | const wxPoint& pos, 55 | const wxSize& size) 56 | :wxChoice(parent, id, pos, size, vals) 57 | { 58 | m_pParent = parent; 59 | m_p_int_selection = p_int_selection; 60 | m_vals = vals; 61 | 62 | if (!(this->SetStringSelection(wxString::Format(wxT("%d"), *m_p_int_selection)))) 63 | { 64 | this->Select(0); 65 | *m_p_int_selection = wxAtoi(this->GetStringSelection()); 66 | } 67 | 68 | wxSize def_best_size = wxChoice::GetBestSize(); 69 | wxSize opt_size = GetOptimalSize(); 70 | 71 | m_vgap = def_best_size.y - opt_size.y; 72 | m_hgap = def_best_size.x - opt_size.x; 73 | } 74 | 75 | CChoice::~CChoice() 76 | { 77 | } 78 | 79 | void CChoice::OnChoice(wxCommandEvent& event) 80 | { 81 | if (m_p_str_selection) 82 | { 83 | *m_p_str_selection = this->GetStringSelection(); 84 | } 85 | else if (m_p_int_selection) 86 | { 87 | *m_p_int_selection = wxAtoi(this->GetStringSelection()); 88 | } 89 | 90 | event.Skip(); 91 | } 92 | 93 | void CChoice::SetFont(wxFont& font) 94 | { 95 | m_pFont = &font; 96 | wxChoice::SetFont(*m_pFont); 97 | } 98 | 99 | void CChoice::SetTextColour(wxColour& colour) 100 | { 101 | m_pTextColour = &colour; 102 | wxChoice::SetForegroundColour(*m_pTextColour); 103 | } 104 | 105 | void CChoice::SetBackgroundColour(wxColour& colour) 106 | { 107 | m_pBackgroundColour = &colour; 108 | wxChoice::SetBackgroundColour(*m_pBackgroundColour); 109 | } 110 | 111 | wxSize CChoice::GetOptimalSize(int vgap, int hgap) 112 | { 113 | wxMemoryDC dc; 114 | if (m_pFont) dc.SetFont(*m_pFont); 115 | wxSize best_size; 116 | 117 | for (const wxString& val : m_vals) 118 | { 119 | wxSize size = dc.GetTextExtent(val); 120 | if (size.x > best_size.x) 121 | { 122 | best_size.x = size.x; 123 | } 124 | if (size.y > best_size.y) 125 | { 126 | best_size.y = size.y; 127 | } 128 | } 129 | 130 | wxSize opt_size; 131 | best_size.x += hgap; 132 | best_size.y += vgap; 133 | 134 | opt_size.x = std::max(best_size.x, m_min_size.x); 135 | opt_size.y = std::max(best_size.y, m_min_size.y); 136 | 137 | return opt_size; 138 | } 139 | 140 | void CChoice::RefreshData() 141 | { 142 | if (m_pFont) wxChoice::SetFont(*m_pFont); 143 | if (m_pTextColour) wxChoice::SetForegroundColour(*m_pTextColour); 144 | if (m_pBackgroundColour) wxChoice::SetBackgroundColour(*m_pBackgroundColour); 145 | 146 | if (m_p_str_selection) 147 | { 148 | if (!(this->SetStringSelection(*m_p_str_selection))) 149 | { 150 | this->Select(0); 151 | *m_p_str_selection = this->GetStringSelection(); 152 | } 153 | } 154 | else if (m_p_int_selection) 155 | { 156 | if (!(this->SetStringSelection(wxString::Format(wxT("%d"), *m_p_int_selection)))) 157 | { 158 | this->Select(0); 159 | *m_p_int_selection = wxAtoi(this->GetStringSelection()); 160 | } 161 | } 162 | 163 | wxSizer* pSizer = GetContainingSizer(); 164 | if (pSizer) 165 | { 166 | wxSize cur_size = this->GetSize(); 167 | wxSize opt_size = GetOptimalSize(m_vgap, m_hgap); 168 | 169 | if (opt_size != cur_size) 170 | { 171 | pSizer->SetItemMinSize(this, opt_size); 172 | pSizer->Layout(); 173 | } 174 | } 175 | } 176 | 177 | void CChoice::SetMinSize(wxSize& size) 178 | { 179 | m_min_size = size; 180 | } 181 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/Choice.h: -------------------------------------------------------------------------------- 1 | //Choice.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include "Control.h" 20 | 21 | class CChoice : public wxChoice, public CControl 22 | { 23 | public: 24 | CChoice(wxWindow* parent, 25 | wxArrayString& vals, 26 | wxString* p_str_selection, 27 | wxWindowID id = wxID_ANY, 28 | const wxPoint& pos = wxDefaultPosition, 29 | const wxSize& size = wxDefaultSize); 30 | 31 | CChoice(wxWindow* parent, 32 | wxArrayString& vals, 33 | int* p_int_selection, 34 | wxWindowID id = wxID_ANY, 35 | const wxPoint& pos = wxDefaultPosition, 36 | const wxSize& size = wxDefaultSize); 37 | 38 | ~CChoice(); 39 | 40 | wxWindow *m_pParent; 41 | 42 | public: 43 | void SetMinSize(wxSize& size); 44 | void SetFont(wxFont& font); 45 | void SetTextColour(wxColour& colour); 46 | void SetBackgroundColour(wxColour& colour); 47 | wxSize GetOptimalSize(int vgap = 0, int hgap = 0); 48 | void RefreshData(); 49 | 50 | void OnChoice(wxCommandEvent& event); 51 | 52 | private: 53 | int m_vgap; 54 | int m_hgap; 55 | wxArrayString m_vals; 56 | wxString* m_p_str_selection = NULL; 57 | int* m_p_int_selection = NULL; 58 | wxSize m_min_size; 59 | wxFont *m_pFont = NULL; 60 | wxColour* m_pTextColour = NULL; 61 | wxColour* m_pBackgroundColour = NULL; 62 | 63 | DECLARE_EVENT_TABLE() 64 | }; 65 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/CommonFunctions.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // Author: Simeon Kosnitsky // 4 | // skosnits@gmail.com // 5 | // // 6 | // License: // 7 | // This software is released into the public domain. You are free to use // 8 | // it in any way you like, except that you may not sell this source code. // 9 | // // 10 | // This software is provided "as is" with no expressed or implied warranty. // 11 | // I accept no liability for any damage or loss of business that this // 12 | // software may cause. // 13 | // // 14 | ////////////////////////////////////////////////////////////////////////////////// 15 | 16 | #include "CommonFunctions.h" 17 | 18 | wxSize get_max_wxSize(vector sizes) 19 | { 20 | wxSize res(0, 0); 21 | 22 | for (int i = 0; i < sizes.size(); i++) 23 | { 24 | if (sizes[i].x > res.x) res.x = sizes[i].x; 25 | if (sizes[i].y > res.y) res.y = sizes[i].y; 26 | } 27 | 28 | return res; 29 | } -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/CommonFunctions.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////// 2 | // // 3 | // Author: Simeon Kosnitsky // 4 | // skosnits@gmail.com // 5 | // // 6 | // License: // 7 | // This software is released into the public domain. You are free to use // 8 | // it in any way you like, except that you may not sell this source code. // 9 | // // 10 | // This software is provided "as is" with no expressed or implied warranty. // 11 | // I accept no liability for any damage or loss of business that this // 12 | // software may cause. // 13 | // // 14 | ////////////////////////////////////////////////////////////////////////////////// 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | using namespace std; 22 | 23 | wxSize get_max_wxSize(vector sizes); -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/Control.h: -------------------------------------------------------------------------------- 1 | //Control.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | 20 | class CControl 21 | { 22 | public: 23 | static std::vector m_all_controls; 24 | 25 | CControl() 26 | { 27 | CControl::m_all_controls.push_back(this); 28 | } 29 | 30 | ~CControl() 31 | { 32 | CControl::m_all_controls.erase(find(CControl::m_all_controls.begin(), CControl::m_all_controls.end(), this)); 33 | } 34 | 35 | static void RefreshAllControlsData() 36 | { 37 | for (int i = 0; i < m_all_controls.size(); i++) 38 | { 39 | m_all_controls[i]->RefreshData(); 40 | } 41 | } 42 | 43 | static void UpdateAllControlsSize() 44 | { 45 | for (int i = m_all_controls.size() - 1; i >= 0; i--) 46 | { 47 | m_all_controls[i]->UpdateSize(); 48 | } 49 | } 50 | 51 | virtual bool UpdateData(wxString* newval) { bool res = true; return res; } 52 | virtual void UpdateSize(){} 53 | 54 | virtual void RefreshData() = 0; 55 | }; 56 | 57 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/DataGrid.h: -------------------------------------------------------------------------------- 1 | //DataGrid.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include "Control.h" 21 | #include "DataTypes.h" 22 | 23 | using namespace std; 24 | 25 | class CDataGrid : public wxGrid, public CControl 26 | { 27 | public: 28 | CDataGrid ( wxWindow* parent, 29 | wxString& grid_col_property_label, 30 | wxString& grid_col_value_label, 31 | wxWindowID id = wxID_ANY, 32 | wxFont* pFont = NULL, 33 | wxColour* pTextColour = NULL, 34 | const wxPoint& pos = wxDefaultPosition, 35 | const wxSize& size = wxDefaultSize ); 36 | ~CDataGrid(); 37 | 38 | public: 39 | int m_w; 40 | int m_h; 41 | wxFont* m_pFont = NULL; 42 | wxColour* m_pTextColour = NULL; 43 | wxColour* m_pGridLineColour = NULL; 44 | wxColour* m_pBackgroundColour = NULL; 45 | wxString* m_p_grid_col_property_label; 46 | wxString* m_p_grid_col_value_label; 47 | 48 | void AddGroup(wxString& label, wxColour& colour); 49 | void AddGroup(wxString&& label, wxColour& colour) = delete; 50 | 51 | void AddSubGroup(wxString& label, wxColour& colour); 52 | void AddSubGroup(wxString&& label, wxColour& colour) = delete; 53 | 54 | void AddProperty(wxString& label, 55 | wxColour& colour1, wxColour& colour2, 56 | wxString *pstr); 57 | void AddProperty(wxString&& label, 58 | wxColour& colour1, wxColour& colour2, 59 | wxString* pstr) = delete; 60 | 61 | void AddProperty(wxString& label, 62 | wxColour& colour1, wxColour& colour2, 63 | wxString *pstr, wxArrayString& vals); 64 | void AddProperty(wxString&& label, 65 | wxColour& colour1, wxColour& colour2, 66 | wxString* pstr, wxArrayString&& vals) = delete; 67 | 68 | void AddProperty(wxString& label, 69 | wxColour& colour1, wxColour& colour2, 70 | wxArrayString* pstr); 71 | void AddProperty(wxString&& label, 72 | wxColour& colour1, wxColour& colour2, 73 | wxArrayString* pstr) = delete; 74 | 75 | void AddProperty(wxString& label, 76 | wxColour& colour1, wxColour& colour2, 77 | int *pval, int val_min, int val_max); 78 | void AddProperty(wxString&& label, 79 | wxColour& colour1, wxColour& colour2, 80 | int* pval, int val_min, int val_max) = delete; 81 | 82 | void AddProperty(wxString& label, 83 | wxColour& colour1, wxColour& colour2, 84 | double *pval, double val_min, double val_max); 85 | void AddProperty(wxString&& label, 86 | wxColour& colour1, wxColour& colour2, 87 | double* pval, double val_min, double val_max) = delete; 88 | 89 | void AddProperty(wxString &label, 90 | wxColour& colour1, wxColour& colour2, 91 | bool *pbln); 92 | void AddProperty(wxString&& label, 93 | wxColour& colour1, wxColour& colour2, 94 | bool* pbln) = delete; 95 | 96 | //void AddSubGroup(); 97 | //bool SetFont(const wxFont& font); 98 | //void SetLabel(const wxString& label); 99 | void SetBackgroundColour(wxColour& col); 100 | //void SetTextColour(const wxColour& colour); 101 | void OnGridCellChanging(wxGridEvent& event); 102 | void OnSize(wxSizeEvent& event); 103 | void SetGridColLaberls(); 104 | void SetGridLineColour(wxColour& col); 105 | wxSize GetOptimalSize(); 106 | void UpdateSize() override; 107 | void RefreshData() override; 108 | 109 | private: 110 | DECLARE_EVENT_TABLE() 111 | }; 112 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/ImageBox.cpp: -------------------------------------------------------------------------------- 1 | //ImageBox.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #include "ImageBox.h" 18 | 19 | BEGIN_EVENT_TABLE(CImageWnd, wxWindow) 20 | EVT_PAINT(CImageWnd::OnPaint) 21 | END_EVENT_TABLE() 22 | 23 | CImageWnd::CImageWnd(CImageBox *pIB) 24 | :wxWindow(pIB, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS) 25 | { 26 | m_pIB = pIB; 27 | } 28 | 29 | CImageWnd::~CImageWnd() 30 | { 31 | } 32 | 33 | void CImageWnd::OnPaint(wxPaintEvent& WXUNUSED(event)) 34 | { 35 | wxPaintDC dc(this); 36 | 37 | if (m_pIB != NULL) 38 | { 39 | if (m_pIB->m_pImage != NULL) 40 | { 41 | int w, h; 42 | this->GetClientSize(&w, &h); 43 | dc.DrawBitmap(m_pIB->m_pImage->Scale(w, h), 0, 0); 44 | } 45 | else 46 | { 47 | dc.Clear(); 48 | } 49 | } 50 | } 51 | 52 | BEGIN_EVENT_TABLE(CImageBox, CResizableWindow) 53 | EVT_SIZE(CImageBox::OnSize) 54 | EVT_KEY_DOWN(CImageBox::OnKeyDown) 55 | EVT_KEY_UP(CImageBox::OnKeyUp) 56 | EVT_MOUSEWHEEL(CImageBox::OnMouseWheel) 57 | EVT_TIMER(TIMER_ID_IB, CImageBox::OnTimer) 58 | EVT_RIGHT_DOWN(CImageBox::OnRButtonDown) 59 | END_EVENT_TABLE() 60 | 61 | void CImageBox::OnRButtonDown(wxMouseEvent& event) 62 | { 63 | SetFocus(); 64 | m_pHW->Popup(); 65 | } 66 | 67 | void CImageBox::OnMouseWheel(wxMouseEvent& event) 68 | { 69 | if ( (m_pImage != NULL) && (g_IsSearching == 0) && (g_IsCreateClearedTextImages == 0) ) 70 | { 71 | wxCommandEvent evt; 72 | 73 | if (event.m_wheelRotation > 0) 74 | { 75 | m_pMF->m_pPanel->m_pSSPanel->OnBnClickedRight(evt); 76 | } 77 | else 78 | { 79 | m_pMF->m_pPanel->m_pSSPanel->OnBnClickedLeft(evt); 80 | } 81 | } 82 | } 83 | 84 | void CImageBox::OnKeyDown(wxKeyEvent& event) 85 | { 86 | std::unique_lock lock(m_mutex); 87 | 88 | s64 Cur; 89 | int key_code = event.GetKeyCode(); 90 | wxCommandEvent evt; 91 | 92 | if (m_pImage != NULL) 93 | { 94 | switch (key_code) 95 | { 96 | case WXK_RIGHT: 97 | if ( (g_IsSearching == 0) && (g_IsCreateClearedTextImages == 0) ) 98 | { 99 | m_pMF->m_pPanel->m_pSSPanel->OnBnClickedRight(evt); 100 | } 101 | break; 102 | 103 | case WXK_LEFT: 104 | if ( (g_IsSearching == 0) && (g_IsCreateClearedTextImages == 0) ) 105 | { 106 | m_pMF->m_pPanel->m_pSSPanel->OnBnClickedLeft(evt); 107 | } 108 | break; 109 | 110 | case 'U': 111 | case 'u': 112 | if (!m_timer.IsRunning()) 113 | { 114 | m_pIW->Reparent(m_pFullScreenWin); 115 | 116 | wxSize cl_size = m_pFullScreenWin->GetClientSize(); 117 | m_pIW->SetSize(0, 0, cl_size.x, cl_size.y); 118 | 119 | m_pFullScreenWin->Show(); 120 | 121 | m_timer.Start(100); 122 | } 123 | 124 | break; 125 | } 126 | } 127 | 128 | switch (key_code) 129 | { 130 | case 'S': 131 | case 's': 132 | if (event.CmdDown()) 133 | { 134 | m_pMF->OnFileSaveSettings(evt); 135 | } 136 | break; 137 | } 138 | } 139 | 140 | void CImageBox::OnKeyUp(wxKeyEvent& event) 141 | { 142 | std::unique_lock lock(m_mutex); 143 | 144 | s64 Cur; 145 | int key_code = event.GetKeyCode(); 146 | wxCommandEvent evt; 147 | 148 | if (m_pImage != NULL) 149 | { 150 | switch (key_code) 151 | { 152 | case 'U': 153 | case 'u': 154 | if (m_timer.IsRunning()) 155 | { 156 | m_timer.Stop(); 157 | wxTimerEvent te; 158 | this->OnTimer(te); 159 | } 160 | 161 | break; 162 | } 163 | } 164 | } 165 | 166 | // note: this is the hack for resolve lost keybard messages if click image in fullscreen 167 | void CImageBox::OnTimer(wxTimerEvent& event) 168 | { 169 | if ( (m_pImage != NULL) && (!wxGetKeyState(wxKeyCode('U')) && !wxGetKeyState(wxKeyCode('u'))) ) 170 | { 171 | if (m_timer.IsRunning()) 172 | { 173 | m_timer.Stop(); 174 | } 175 | 176 | if (m_pFullScreenWin->IsShown()) 177 | { 178 | m_pFullScreenWin->Hide(); 179 | m_pIW->Reparent(this); 180 | 181 | m_pHW->Hide(); 182 | 183 | wxSizeEvent event; 184 | OnSize(event); 185 | 186 | this->SetFocus(); 187 | } 188 | } 189 | } 190 | 191 | CImageBox::CImageBox(CMainFrame* pMF) 192 | : CResizableWindow(pMF, 193 | wxID_ANY, 194 | wxDefaultPosition, wxDefaultSize), m_timer(this, TIMER_ID_IB) 195 | { 196 | m_pMF = pMF; 197 | m_pImage = NULL; 198 | m_WasInited = false; 199 | m_pFullScreenWin = NULL; 200 | } 201 | 202 | CImageBox::~CImageBox() 203 | { 204 | if (m_pImage != NULL) 205 | { 206 | delete m_pImage; 207 | m_pImage = NULL; 208 | } 209 | 210 | if (m_pFullScreenWin != NULL) 211 | { 212 | m_pFullScreenWin->Destroy(); 213 | } 214 | 215 | if (m_pHW != NULL) 216 | { 217 | m_pHW->Destroy(); 218 | } 219 | } 220 | 221 | void CImageBox::Init() 222 | { 223 | wxString strIBClass; 224 | wxString strIBXClass; 225 | 226 | int w = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); 227 | int h = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); 228 | 229 | m_pFullScreenWin = new wxFrame(m_pMF, wxID_ANY, wxT(""), wxPoint(0, 0), wxSize(w, h), wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT); 230 | m_pFullScreenWin->ShowFullScreen(true); 231 | m_pFullScreenWin->Hide(); 232 | 233 | m_plblIB = new CStaticText(this, g_cfg.m_image_box_title, ID_LBL_IB); 234 | m_plblIB->SetSize(0, 0, 390, 30); 235 | m_plblIB->SetFont(m_pMF->m_LBLFont); 236 | m_plblIB->SetTextColour(g_cfg.m_main_text_colour); 237 | m_plblIB->SetBackgroundColour(g_cfg.m_video_image_box_title_colour); 238 | 239 | m_pIW = new CImageWnd(this); 240 | m_pIW->SetBackgroundColour(g_cfg.m_video_image_box_background_colour); 241 | 242 | this->SetBackgroundColour(g_cfg.m_video_image_box_border_colour); 243 | this->SetSize(20,20,402,300); 244 | 245 | m_pHW = new CPopupHelpWindow(g_cfg.m_help_desc_hotkeys_for_image_box); 246 | 247 | m_plblIB->Bind(wxEVT_MOTION, &CResizableWindow::OnMouseMove, this); 248 | m_plblIB->Bind(wxEVT_LEAVE_WINDOW, &CResizableWindow::OnMouseLeave, this); 249 | m_plblIB->Bind(wxEVT_LEFT_DOWN, &CResizableWindow::OnLButtonDown, this); 250 | m_plblIB->Bind(wxEVT_LEFT_UP, &CResizableWindow::OnLButtonUp, this); 251 | m_plblIB->Bind(wxEVT_RIGHT_DOWN, &CImageBox::OnRButtonDown, this); 252 | m_plblIB->m_pST->Bind(wxEVT_MOTION, &CResizableWindow::OnMouseMove, this); 253 | m_plblIB->m_pST->Bind(wxEVT_LEAVE_WINDOW, &CResizableWindow::OnMouseLeave, this); 254 | m_plblIB->m_pST->Bind(wxEVT_LEFT_DOWN, &CResizableWindow::OnLButtonDown, this); 255 | m_plblIB->m_pST->Bind(wxEVT_LEFT_UP, &CResizableWindow::OnLButtonUp, this); 256 | m_plblIB->m_pST->Bind(wxEVT_RIGHT_DOWN, &CImageBox::OnRButtonDown, this); 257 | 258 | m_pIW->Bind(wxEVT_KEY_DOWN, &CImageBox::OnKeyDown, this); 259 | m_pIW->Bind(wxEVT_KEY_UP, &CImageBox::OnKeyUp, this); 260 | m_pIW->Bind(wxEVT_MOUSEWHEEL, &CImageBox::OnMouseWheel, this); 261 | m_pIW->Bind(wxEVT_RIGHT_DOWN, &CImageBox::OnRButtonDown, this); 262 | 263 | m_WasInited = true; 264 | } 265 | 266 | void CImageBox::UpdateSize() 267 | { 268 | wxSizeEvent event; 269 | OnSize(event); 270 | } 271 | 272 | void CImageBox::RefreshData() 273 | { 274 | this->SetBackgroundColour(g_cfg.m_video_image_box_border_colour); 275 | m_pIW->SetBackgroundColour(g_cfg.m_video_image_box_background_colour); 276 | } 277 | 278 | void CImageBox::OnSize( wxSizeEvent& event ) 279 | { 280 | int w, h; 281 | wxRect rcClIB, rlIB, rcIW; 282 | wxSize lblVB_opt_size = m_pMF->m_pVideoBox ? m_pMF->m_pVideoBox->m_plblVB->GetOptimalSize() : wxSize(0, 0); 283 | wxSize lblIB_opt_size = m_plblIB->GetOptimalSize(); 284 | 285 | this->GetClientSize(&w, &h); 286 | rcClIB.x = rcClIB.y = 0; 287 | rcClIB.width = w; 288 | rcClIB.y = h; 289 | 290 | rlIB.x = 0; 291 | rlIB.y = 0; 292 | rlIB.width = rcClIB.width; 293 | rlIB.height = std::max(lblVB_opt_size.y, lblIB_opt_size.y); 294 | 295 | rcIW.x = 9; 296 | rcIW.y = rlIB.GetBottom() + 9; 297 | rcIW.width = rcClIB.width - rcIW.x*2; 298 | rcIW.height = rcClIB.GetBottom() - 9 - rcIW.y; 299 | 300 | m_plblIB->SetSize(rlIB); 301 | m_pIW->SetSize(rcIW); 302 | 303 | m_pIW->Refresh(false); 304 | m_pIW->Update(); 305 | } 306 | 307 | void CImageBox::ClearScreen() 308 | { 309 | if (m_pImage != NULL) 310 | { 311 | int w, h; 312 | m_pIW->GetClientSize(&w, &h); 313 | 314 | delete m_pImage; 315 | m_pImage = new wxImage(w, h); 316 | } 317 | m_pIW->Refresh(false); 318 | } 319 | 320 | void CImageBox::ViewRGBImage(simple_buffer &Im, int w, int h) 321 | { 322 | int num_pixels = w*h; 323 | u8 *color; 324 | 325 | unsigned char *img_data = (unsigned char*)malloc(num_pixels * 3); // auto released by wxImage 326 | 327 | for (int i = 0; i < num_pixels; i++) 328 | { 329 | color = (u8*)(&Im[i]); 330 | img_data[i * 3] = color[2]; 331 | img_data[i * 3 + 1] = color[1]; 332 | img_data[i * 3 + 2] = color[0]; 333 | } 334 | 335 | { 336 | std::lock_guard guard(m_view_mutex); 337 | 338 | if (m_pImage != NULL) delete m_pImage; 339 | m_pImage = new wxImage(w, h, img_data); 340 | 341 | m_pIW->Refresh(false); 342 | m_pIW->Update(); 343 | } 344 | } 345 | 346 | void CImageBox::ViewGrayscaleImage(simple_buffer &Im, int w, int h) 347 | { 348 | int num_pixels = w*h; 349 | 350 | unsigned char *img_data = (unsigned char*)malloc(num_pixels * 3); // auto released by wxImage 351 | 352 | for (int i = 0; i < num_pixels; i++) 353 | { 354 | img_data[i * 3] = Im[i]; 355 | img_data[i * 3 + 1] = Im[i]; 356 | img_data[i * 3 + 2] = Im[i]; 357 | } 358 | 359 | { 360 | std::lock_guard guard(m_view_mutex); 361 | 362 | if (m_pImage != NULL) delete m_pImage; 363 | m_pImage = new wxImage(w, h, img_data); 364 | 365 | m_pIW->Refresh(false); 366 | m_pIW->Update(); 367 | } 368 | } 369 | 370 | void CImageBox::ViewImage(simple_buffer &Im, int w, int h) 371 | { 372 | int num_pixels = w*h; 373 | u8 *color; 374 | 375 | unsigned char *img_data = (unsigned char*)malloc(num_pixels * 3); // auto released by wxImage 376 | 377 | for (int i = 0; i < num_pixels; i++) 378 | { 379 | color = (u8*)(&Im[i]); 380 | img_data[i * 3] = color[0]; 381 | img_data[i * 3 + 1] = color[0]; 382 | img_data[i * 3 + 2] = color[0]; 383 | } 384 | 385 | { 386 | std::lock_guard guard(m_view_mutex); 387 | 388 | if (m_pImage != NULL) delete m_pImage; 389 | m_pImage = new wxImage(w, h, img_data); 390 | 391 | m_pIW->Refresh(false); 392 | m_pIW->Update(); 393 | } 394 | } 395 | 396 | void CImageBox::ViewBGRImage(simple_buffer& ImBGR, int w, int h) 397 | { 398 | int num_pixels = w * h; 399 | unsigned char* img_data = (unsigned char*)malloc(num_pixels * 3); // auto released by wxImage 400 | 401 | for (int i = 0; i < num_pixels; i++) 402 | { 403 | img_data[i * 3] = ImBGR[i * 3 + 2]; 404 | img_data[i * 3 + 1] = ImBGR[i * 3 + 1]; 405 | img_data[i * 3 + 2] = ImBGR[i * 3]; 406 | } 407 | 408 | { 409 | std::lock_guard guard(m_view_mutex); 410 | 411 | if (m_pImage != NULL) delete m_pImage; 412 | m_pImage = new wxImage(w, h, img_data); 413 | 414 | m_pIW->Refresh(false); 415 | m_pIW->Update(); 416 | } 417 | } 418 | 419 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/ImageBox.h: -------------------------------------------------------------------------------- 1 | //ImageBox.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include "MyResource.h" 21 | #include "MainFrm.h" 22 | #include "StaticText.h" 23 | #include "ResizableWindow.h" 24 | #include "Control.h" 25 | 26 | class CImageBox; 27 | class CPopupHelpWindow; 28 | 29 | class CImageWnd : public wxWindow 30 | { 31 | public: 32 | CImageWnd(CImageBox *pIB); 33 | ~CImageWnd(); 34 | 35 | CImageBox *m_pIB; 36 | 37 | public: 38 | void OnPaint( wxPaintEvent &event ); 39 | 40 | private: 41 | DECLARE_EVENT_TABLE() 42 | }; 43 | 44 | class CImageBox : public CResizableWindow, public CControl 45 | { 46 | public: 47 | CImageBox(CMainFrame* pMF); // protected constructor used by dynamic creation 48 | ~CImageBox(); 49 | 50 | CStaticText *m_plblIB; 51 | CImageWnd *m_pIW; 52 | 53 | bool m_WasInited; 54 | 55 | wxImage *m_pImage; 56 | wxFrame *m_pFullScreenWin; 57 | wxTimer m_timer; 58 | 59 | CPopupHelpWindow* m_pHW; 60 | 61 | std::mutex m_mutex; 62 | 63 | CMainFrame* m_pMF; 64 | 65 | public: 66 | void Init(); 67 | void ResizeControls(); 68 | 69 | void ViewRGBImage(simple_buffer &Im, int w, int h); 70 | void ViewGrayscaleImage(simple_buffer &Im, int w, int h); 71 | void ViewImage(simple_buffer &Im, int w, int h); 72 | void ViewBGRImage(simple_buffer& ImBGR, int w, int h); 73 | void ClearScreen(); 74 | void UpdateSize() override; 75 | void RefreshData() override; 76 | 77 | public: 78 | void OnSize(wxSizeEvent& event); 79 | void OnKeyDown(wxKeyEvent& event); 80 | void OnKeyUp(wxKeyEvent& event); 81 | void OnMouseWheel(wxMouseEvent& event); 82 | void OnTimer(wxTimerEvent& event); 83 | void OnRButtonDown(wxMouseEvent& event); 84 | 85 | private: 86 | std::mutex m_view_mutex; 87 | 88 | DECLARE_EVENT_TABLE() 89 | }; 90 | 91 | 92 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/MyResource.h: -------------------------------------------------------------------------------- 1 | //MyResource.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #define VSF_VERSION "6.10" 20 | 21 | #define ID_APP_ABOUT 1100 22 | 23 | #define ID_LBL_BT1 1200 24 | #define ID_LBL_BTA1 1201 25 | #define ID_LBL_BT2 1202 26 | #define ID_LBL_BTA2 1203 27 | #define ID_BTN_RUN 1204 28 | #define ID_LBL_LNH 1205 29 | #define ID_LBL_POS 1206 30 | #define ID_LBL_HVT 1207 31 | #define ID_LBL_MDT 1208 32 | #define ID_TAB 1209 33 | #define ID_LBL_PLF 1213 34 | #define ID_LBL_TCO 1214 35 | #define ID_LBL_BTD 1215 36 | #define ID_PNL_SEARCH 1216 37 | #define ID_PNL_SETTINGS 1217 38 | #define ID_PANEL3 1218 39 | #define ID_LBL_SW 1219 40 | #define ID_BK 1220 41 | #define ID_LBL_PPCE 1221 42 | #define ID_LBL_MPD 1222 43 | #define ID_LBL_MPN 1223 44 | #define ID_LBL_PCF 1224 45 | #define ID_MDT 1225 46 | #define ID_HVT 1226 47 | #define ID_LNH 1227 48 | #define ID_BTD 1228 49 | #define ID_TCO 1229 50 | #define ID_MPN 1230 51 | #define ID_MPD 1231 52 | #define ID_SW 1232 53 | #define ID_LBL_SCD 1233 54 | #define ID_LBL_MSC 1234 55 | #define ID_MSC 1235 56 | #define ID_SCD 1236 57 | #define ID_LBL_SMCD 1237 58 | #define ID_SMCD 1238 59 | #define ID_LBL_VEPLE 1239 60 | #define ID_LBL_PFFS 1240 61 | #define ID_LBL_SSE 1241 62 | #define ID_LBL_SFL 1242 63 | #define ID_SFL 1243 64 | #define ID_SSE 1244 65 | #define ID_VEPLE 1245 66 | #define ID_LBL_PFCS 1246 67 | #define ID_LBL_TP 1247 68 | #define ID_LBL_PFFTS 1248 69 | #define ID_LBL_LLE 1249 70 | #define ID_TP 1250 71 | #define ID_LBL_MTL 1251 72 | #define ID_MTL 1252 73 | #define ID_LBL_PFVS 1253 74 | #define ID_LBL_DE 1254 75 | #define ID_DE 1255 76 | #define ID_LLE 1256 77 | #define ID_TEST 1257 78 | #define ID_GB1 1258 79 | #define ID_GB2 1259 80 | #define ID_BTN_CCTI 1260 81 | #define ID_BTN_CES 1261 82 | 83 | #define ID_LBL_VB 1262 84 | #define ID_LBL_TIME 1263 85 | 86 | #define ID_TRACKBAR 1264 87 | #define ID_LINE 1265 88 | #define ID_BOX 1266 89 | #define ID_VBOX 1267 90 | 91 | #define ID_LBL_IB 1268 92 | #define ID_IBOX 1269 93 | 94 | #define ID_BTN_CLEAR 1270 95 | 96 | #define ID_SP_LEFT 1271 97 | #define ID_SP_RIGHT 1272 98 | #define ID_LBL_IF 1273 99 | #define IDC_SCROLL1 1274 100 | #define ID_OI 1275 101 | #define ID_OIM 1276 102 | #define ID_GB3 1277 103 | 104 | #define ID_BTN_TEST 1278 105 | #define ID_BTN_CSTXT 1279 106 | #define ID_BTN_CSCTI 1280 107 | 108 | #define ID_BTN_JOIN 1281 109 | 110 | #define ID_LBL_BEGIN_TIME 1282 111 | 112 | #define ID_LBL_END_TIME 1283 113 | 114 | 115 | /////////////////////////////////////////////////////////// 116 | 117 | #define IDR_MAINFRAME 1 118 | #define IDR_MENU 2 119 | #define IDM_HELLO 3 120 | #define IDM_BLACK 4 121 | #define IDM_RED 5 122 | #define IDM_GREEN 6 123 | #define IDM_BLUE 7 124 | #define IDM_WHITE 8 125 | #define IDM_CUSTOM 9 126 | #define IDM_FAST 10 127 | #define IDM_SLOW 11 128 | #define IDD_ABOUTBOX 12 129 | #define IDR_VIDEOBAR 13 130 | #define IDB_RIGHT_NA 14 131 | #define IDB_RIGHT_OD 15 132 | #define IDB_LEFT_NA 16 133 | #define IDB_LEFT_OD 17 134 | #define IDB_HORIZONTAL_SCROLLBAR_THUMB_NO_COLOR 18 135 | #define IDB_HORIZONTAL_SCROLLBAR_CHANNEL 19 136 | #define IDB_HORIZONTAL_SCROLLBAR_LEFTARROW 20 137 | #define IDB_HORIZONTAL_SCROLLBAR_RIGHTARROW 21 138 | #define IDB_HORIZONTAL_SCROLLBAR_THUMB 22 139 | #define IDB_VERTICAL_SCROLLBAR_THUMB_NO_COLOR 23 140 | #define IDB_VERTICAL_SCROLLBAR_UPARROW 24 141 | #define IDB_VERTICAL_SCROLLBAR_CHANNEL 25 142 | #define IDB_VERTICAL_SCROLLBAR_DOWNARROW 26 143 | #define IDB_VERTICAL_SCROLLBAR_THUMB 27 144 | #define ID_BUTTON32786 28 145 | #define ID_BUTTON32787 29 146 | #define ID_BUTTON32788 30 147 | #define ID_FILE_SAVESETTINGS 31 148 | #define ID_FILE_SAVESETTINGSAS 32 149 | #define ID_FILE_LOADSETTINGS 33 150 | #define ID_EDIT_SETBEGINTIME 34 151 | #define ID_EDIT_SETENDTIME 35 152 | #define ID_PLAY_PLAY 36 153 | #define ID_PLAY_STOP 37 154 | #define ID_TB_RUN 38 155 | #define ID_TB_PAUSE 39 156 | #define ID_TB_STOP 40 157 | #define ID_PLAY_PAUSE 41 158 | #define ID_LBL_MSD 42 159 | #define ID_MSD 43 160 | #define ID_FILE_OPENPREVIOUSVIDEO 44 161 | #define ID_Menu 45 162 | #define ID_FILE_OPEN_VIDEO_OPENCV 46 163 | #define ID_FILE_OPEN_VIDEO_FFMPEG 47 164 | #define ID_FILE_REOPENVIDEO 48 165 | #define ID_FILE_EXIT 49 166 | #define ID_Menu57808 50 167 | #define ID_SETPRIORITY 51 168 | #define ID_SETPRIORITY_IDLE 52 169 | #define ID_SETPRIORITY_ABOVENORMAL 53 170 | #define ID_SETPRIORITY_NORMAL 54 171 | #define ID_SETPRIORITY_BELOWNORMAL 55 172 | #define ID_SETPRIORITY_HIGH 56 173 | #define ID_FILE_RETERT 57 174 | #define ID_RETERT_ERTRT 58 175 | #define ID_RETERT_RETERT 59 176 | #define _APS_NEXT_RESOURCE_VALUE 60 177 | #define _APS_NEXT_COMMAND_VALUE 61 178 | #define _APS_NEXT_CONTROL_VALUE 62 179 | #define _APS_NEXT_SYMED_VALUE 63 180 | #define TIMER_ID 64 181 | #define TIMER_ID_VB 65 182 | #define ID_SCALE_TEXT_SIZE_INC 66 183 | #define ID_SCALE_TEXT_SIZE_DEC 67 184 | #define ID_NEXT_FRAME 68 185 | #define ID_PREVIOUS_FRAME 69 186 | #define ID_APP_CMD_ARGS_INFO 70 187 | #define ID_APP_USAGE_DOCS 71 188 | #define ID_FONTS 72 189 | #define ID_APP_WEBSITE 73 190 | #define ID_APP_FORUM 74 191 | #define ID_APP_BUG_TRACKER 75 192 | #define TIMER_ID_IB 76 193 | 194 | // !NOTE: SHOULD BE WITH THE HIGHEST VALUE 195 | #define FIRST_ID_FOR_LOCALIZATIONS 77 196 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/OCRPanel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Interfaces/VideoSubFinderWXW/OCRPanel.h -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/ResizableWindow.cpp: -------------------------------------------------------------------------------- 1 | 2 | //ResizableWindow.cpp// 3 | ////////////////////////////////////////////////////////////////////////////////// 4 | // // 5 | // Author: Simeon Kosnitsky // 6 | // skosnits@gmail.com // 7 | // // 8 | // License: // 9 | // This software is released into the public domain. You are free to use // 10 | // it in any way you like, except that you may not sell this source code. // 11 | // // 12 | // This software is provided "as is" with no expressed or implied warranty. // 13 | // I accept no liability for any damage or loss of business that this // 14 | // software may cause. // 15 | // // 16 | ////////////////////////////////////////////////////////////////////////////////// 17 | 18 | #include "ResizableWindow.h" 19 | 20 | BEGIN_EVENT_TABLE(CResizableWindow, wxWindow) 21 | EVT_LEFT_DOWN(CResizableWindow::OnLButtonDown) 22 | EVT_LEFT_UP(CResizableWindow::OnLButtonUp) 23 | EVT_MOTION(CResizableWindow::OnMouseMove) 24 | EVT_LEAVE_WINDOW(CResizableWindow::OnMouseLeave) 25 | EVT_MOUSE_CAPTURE_LOST(CResizableWindow::OnMouseCaptureLost) 26 | END_EVENT_TABLE() 27 | 28 | 29 | CResizableWindow::CResizableWindow(wxWindow* parent, wxWindowID id, 30 | const wxPoint& pos, 31 | const wxSize& size) 32 | : wxWindow(parent, id, pos, size, wxWANTS_CHARS) 33 | { 34 | } 35 | 36 | CResizableWindow::~CResizableWindow() 37 | { 38 | } 39 | 40 | void CResizableWindow::OnLButtonDown(wxMouseEvent& event) 41 | { 42 | wxPoint clao = GetClientAreaOrigin(); 43 | wxPoint mp = wxGetMousePosition() - GetScreenPosition() - clao; 44 | event.m_x = mp.x; 45 | event.m_y = mp.y; 46 | 47 | if (!this->HasFocus()) 48 | { 49 | this->SetFocus(); 50 | } 51 | 52 | int x = event.m_x, y = event.m_y, w, h; 53 | this->GetClientSize(&w, &h); 54 | 55 | if ((x < m_border_size) || 56 | (x > w - m_border_size - 1) || 57 | (y < m_border_size) || 58 | (y > h - m_border_size - 1)) 59 | { 60 | m_bDownResize = true; 61 | 62 | UpdateCursor(event.m_x, event.m_y); 63 | 64 | if (x < m_border_size) 65 | m_bDownFromLeft = true; 66 | else 67 | m_bDownFromLeft = false; 68 | 69 | if (x > w - m_border_size - 1) 70 | m_bDownFromRight = true; 71 | else 72 | m_bDownFromRight = false; 73 | 74 | if (y < m_border_size) 75 | m_bDownFromTop = true; 76 | else 77 | m_bDownFromTop = false; 78 | 79 | if (y > h - m_border_size - 1) 80 | m_bDownFromBottom = true; 81 | else 82 | m_bDownFromBottom = false; 83 | 84 | this->Raise(); 85 | this->CaptureMouse(); 86 | } 87 | else if (y < m_move_border_size) 88 | { 89 | m_bDownMove = true; 90 | m_dm_orig_point = wxPoint(event.m_x, event.m_y); 91 | //UpdateCursor(event.m_x, event.m_y); 92 | m_cur_cursor = wxCURSOR_HAND; 93 | this->SetCursor(wxCursor(m_cur_cursor)); 94 | this->Raise(); 95 | this->CaptureMouse(); 96 | } 97 | } 98 | 99 | void CResizableWindow::OnLButtonUp(wxMouseEvent& event) 100 | { 101 | if ((m_bDownResize == true) || (m_bDownMove == true)) 102 | { 103 | m_bDownResize = false; 104 | m_bDownMove = false; 105 | m_cur_cursor = wxCURSOR_ARROW; 106 | this->SetCursor(wxCursor(m_cur_cursor)); 107 | this->ReleaseMouse(); 108 | this->Refresh(true); 109 | } 110 | } 111 | 112 | void CResizableWindow::UpdateCursor(int x, int y) 113 | { 114 | wxStockCursor set_cursor = wxCURSOR_ARROW; 115 | 116 | int w, h; 117 | this->GetClientSize(&w, &h); 118 | 119 | if ((x < m_border_size) || 120 | (x > w - m_border_size - 1) || 121 | (y < m_border_size) || 122 | (y > h - m_border_size - 1)) 123 | { 124 | if (((x < m_border_size) && (y < m_border_size)) || 125 | ((x > w - m_border_size - 1) && (y > h - m_border_size - 1))) 126 | { 127 | set_cursor = wxCURSOR_SIZENWSE; 128 | } 129 | else if (((x < m_border_size) && (y > h - m_border_size - 1)) || 130 | ((x > w - m_border_size - 1) && (y < m_border_size))) 131 | { 132 | set_cursor = wxCURSOR_SIZENESW; 133 | } 134 | else if ((x < m_border_size) || 135 | (x > w - m_border_size - 1)) 136 | { 137 | set_cursor = wxCURSOR_SIZEWE; 138 | } 139 | else 140 | { 141 | set_cursor = wxCURSOR_SIZENS; 142 | } 143 | } 144 | 145 | if (m_cur_cursor != set_cursor) 146 | { 147 | m_cur_cursor = set_cursor; 148 | this->SetCursor(wxCursor(m_cur_cursor)); 149 | } 150 | } 151 | 152 | void CResizableWindow::OnMouseLeave(wxMouseEvent& event) 153 | { 154 | if ((m_bDownResize == false) && (m_bDownMove == false)) 155 | { 156 | m_cur_cursor = wxCURSOR_ARROW; 157 | this->SetCursor(wxCursor(m_cur_cursor)); 158 | } 159 | } 160 | 161 | void CResizableWindow::OnMouseCaptureLost(wxMouseCaptureLostEvent& event) 162 | { 163 | if ((m_bDownResize == true) || (m_bDownMove == true)) 164 | { 165 | m_bDownResize = false; 166 | m_bDownMove = false; 167 | 168 | m_cur_cursor = wxCURSOR_ARROW; 169 | this->SetCursor(wxCursor(m_cur_cursor)); 170 | } 171 | } 172 | 173 | void CResizableWindow::OnMouseMove(wxMouseEvent& event) 174 | { 175 | wxPoint clao = GetClientAreaOrigin(); 176 | wxPoint mp = wxGetMousePosition() - GetScreenPosition() - clao; 177 | event.m_x = mp.x; 178 | event.m_y = mp.y; 179 | 180 | wxPoint pt = this->GetPosition(); 181 | wxSize border = this->GetWindowBorderSize(); 182 | int x = pt.x + border.GetWidth() + event.m_x, y = pt.y + border.GetHeight() + event.m_y, w, h, val; 183 | wxSize ps = this->GetParent()->GetClientSize(); 184 | 185 | wxRect rc = this->GetRect(); 186 | wxRect orig_rc = rc; 187 | w = rc.width; 188 | h = rc.height; 189 | 190 | if (m_bDownResize == true) 191 | { 192 | if (m_bDownFromLeft) 193 | { 194 | val = rc.x + w - x; 195 | if ((val > 2 * m_border_size + 10) && (x >= 0)) 196 | { 197 | rc.width = val; 198 | rc.x = x; 199 | } 200 | } 201 | 202 | if (m_bDownFromRight) 203 | { 204 | val = x - rc.x; 205 | if ((val > 2 * m_border_size + 10) && (x < ps.x)) 206 | { 207 | rc.width = val; 208 | } 209 | } 210 | 211 | if (m_bDownFromTop) 212 | { 213 | val = rc.y + h - y; 214 | if ((val > 2 * m_border_size + 10) && (y >= 0)) 215 | { 216 | rc.height = val; 217 | rc.y = y; 218 | } 219 | } 220 | 221 | if (m_bDownFromBottom) 222 | { 223 | val = y - rc.y; 224 | if ((val > 2 * m_border_size + 10) && (y < ps.y)) 225 | { 226 | rc.height = val; 227 | } 228 | } 229 | 230 | if (rc != orig_rc) 231 | { 232 | //this->Show(false); 233 | this->SetSize(rc); 234 | //this->Show(true); 235 | //this->Raise(); 236 | //this->Refresh(true); 237 | } 238 | } 239 | else if (m_bDownMove == true) 240 | { 241 | int dx = event.m_x - m_dm_orig_point.x; 242 | int dy = event.m_y - m_dm_orig_point.y; 243 | 244 | if ((rc.x + w + dx > m_move_border_size) && (rc.x + dx < ps.x - m_move_border_size)) 245 | rc.x += dx; 246 | 247 | if ((rc.y + dy >= 0) && (rc.y + dy < ps.y - m_move_border_size)) 248 | rc.y += dy; 249 | 250 | if (rc != orig_rc) 251 | { 252 | //this->Show(false); 253 | this->SetSize(rc); 254 | //this->Show(true); 255 | //this->Raise(); 256 | //this->Refresh(true); 257 | } 258 | } 259 | else 260 | { 261 | UpdateCursor(event.m_x, event.m_y); 262 | } 263 | } -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/ResizableWindow.h: -------------------------------------------------------------------------------- 1 | //ResizableWindow.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | 20 | class CResizableWindow : public wxWindow 21 | { 22 | public: 23 | CResizableWindow(wxWindow* parent, wxWindowID id = wxID_ANY, 24 | const wxPoint& pos = wxDefaultPosition, 25 | const wxSize& size = wxDefaultSize); 26 | ~CResizableWindow(); 27 | 28 | void OnLButtonDown(wxMouseEvent& event); 29 | void OnLButtonUp(wxMouseEvent& event); 30 | void OnMouseMove(wxMouseEvent& event); 31 | void OnMouseLeave(wxMouseEvent& event); 32 | void OnMouseCaptureLost(wxMouseCaptureLostEvent& event); 33 | 34 | void UpdateCursor(int x, int y); 35 | 36 | int m_border_size = 4; 37 | int m_move_border_size = 40; 38 | bool m_bDownResize = false; 39 | bool m_bDownFromLeft = false; 40 | bool m_bDownFromRight = false; 41 | bool m_bDownFromTop = false; 42 | bool m_bDownFromBottom = false; 43 | bool m_bDownMove = false; 44 | wxPoint m_dm_orig_point; 45 | wxStockCursor m_cur_cursor = wxCURSOR_ARROW; 46 | 47 | private: 48 | DECLARE_EVENT_TABLE() 49 | }; -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/SSOWnd.cpp: -------------------------------------------------------------------------------- 1 | //SSOWnd.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #define _HAS_STD_BYTE 0 18 | #include "SSOWnd.h" 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | 22 | CTabArt::CTabArt(CMainFrame* pMF) : wxAuiGenericTabArt() 23 | { 24 | m_pMF = pMF; 25 | } 26 | 27 | void CTabArt::DrawTab(wxDC& dc, 28 | wxWindow* wnd, 29 | const wxAuiNotebookPage& pane, 30 | const wxRect& inRect, 31 | int closeButtonState, 32 | wxRect* outTabRect, 33 | wxRect* outButtonRect, 34 | int* xExtent) 35 | { 36 | SetColour(g_cfg.m_notebook_colour); 37 | SetActiveColour(g_cfg.m_notebook_colour); 38 | SetNormalFont(m_pMF->m_LBLFont); 39 | SetSelectedFont(m_pMF->m_LBLFont); 40 | SetMeasuringFont(m_pMF->m_LBLFont); 41 | wxAuiGenericTabArt::DrawTab(dc, wnd, pane, inRect, closeButtonState, outTabRect, outButtonRect, xExtent); 42 | } 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | 46 | CSSOWnd::CSSOWnd(CMainFrame* pMF) 47 | : wxAuiNotebook(pMF, wxID_ANY, wxDefaultPosition, wxSize(400, 300), 48 | wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | 49 | wxAUI_NB_SCROLL_BUTTONS | wxBORDER ) 50 | { 51 | m_pMF = pMF; 52 | m_WasInited = false; 53 | m_pTabArt = NULL; 54 | } 55 | 56 | ///////////////////////////////////////////////////////////////////////////// 57 | 58 | CSSOWnd::~CSSOWnd() 59 | { 60 | } 61 | 62 | ///////////////////////////////////////////////////////////////////////////// 63 | 64 | void CSSOWnd::Init() 65 | { 66 | wxString strPClass; 67 | 68 | SaveToReportLog("CSSOWnd::Init(): starting...\n"); 69 | 70 | SetBackgroundColour(g_cfg.m_notebook_colour); 71 | 72 | this->SetFont(m_pMF->m_LBLFont); 73 | 74 | m_pTabArt = new CTabArt(m_pMF); 75 | SetArtProvider(m_pTabArt); 76 | 77 | SaveToReportLog("CSSOWnd::Init(): new CSearchPanel(this)...\n"); 78 | m_pSHPanel = new CSearchPanel(this); 79 | SaveToReportLog("CSSOWnd::Init(): new CSettingsPanel(this)...\n"); 80 | m_pSSPanel = new CSettingsPanel(this); 81 | SaveToReportLog("CSSOWnd::Init(): new COCRPanel(this)...\n"); 82 | m_pOCRPanel = new COCRPanel(this); 83 | SaveToReportLog("CSSOWnd::Init(): m_pSHPanel->Init()...\n"); 84 | m_pSHPanel->Init(); 85 | SaveToReportLog("CSSOWnd::Init(): m_pSSPanel->Init()...\n"); 86 | m_pSSPanel->Init(); 87 | SaveToReportLog("CSSOWnd::Init(): m_pOCRPanel->Init()...\n"); 88 | m_pOCRPanel->Init(); 89 | 90 | wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); 91 | 92 | SaveToReportLog("CSSOWnd::Init(): AddPage's...\n"); 93 | 94 | this->AddPage(m_pSHPanel, g_cfg.m_search_panel_title, false, page_bmp ); 95 | this->AddPage(m_pSSPanel, g_cfg.m_settings_panel_title, false, page_bmp ); 96 | this->AddPage(m_pOCRPanel, g_cfg.m_ocr_panel_title, false, page_bmp ); 97 | 98 | SetTabCtrlHeight(-1); 99 | 100 | m_WasInited = true; 101 | 102 | SaveToReportLog("CSSOWnd::Init(): finished.\n"); 103 | } 104 | 105 | void CSSOWnd::RefreshData() 106 | { 107 | SetBackgroundColour(g_cfg.m_notebook_colour); 108 | 109 | this->SetPageText(0, g_cfg.m_search_panel_title); 110 | this->SetPageText(1, g_cfg.m_settings_panel_title); 111 | this->SetPageText(2, g_cfg.m_ocr_panel_title); 112 | 113 | this->SetFont(m_pMF->m_LBLFont); 114 | SetTabCtrlHeight(-1); 115 | } 116 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/SSOWnd.h: -------------------------------------------------------------------------------- 1 | //SSOWnd.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include "MyResource.h" 21 | #include "SearchPanel.h" 22 | #include "SettingsPanel.h" 23 | #include "OCRPanel.h" 24 | #include "MainFrm.h" 25 | #include "Control.h" 26 | 27 | class CMainFrame; 28 | class CSearchPanel; 29 | class CSettingsPanel; 30 | class COCRPanel; 31 | 32 | class CTabArt : public wxAuiGenericTabArt 33 | { 34 | public: 35 | CMainFrame* m_pMF; 36 | 37 | CTabArt(CMainFrame* pMF); 38 | 39 | wxAuiTabArt* Clone() wxOVERRIDE 40 | { 41 | return new CTabArt(*this); 42 | } 43 | 44 | void DrawTab(wxDC& dc, 45 | wxWindow* wnd, 46 | const wxAuiNotebookPage& pane, 47 | const wxRect& inRect, 48 | int closeButtonState, 49 | wxRect* outTabRect, 50 | wxRect* outButtonRect, 51 | int* xExtent) wxOVERRIDE; 52 | }; 53 | 54 | class CSSOWnd : public wxAuiNotebook, public CControl 55 | { 56 | public: 57 | CSSOWnd(CMainFrame* pMF); // protected constructor used by dynamic creation 58 | ~CSSOWnd(); 59 | 60 | //wxAuiNotebook *m_pAN; 61 | CSearchPanel *m_pSHPanel; 62 | CSettingsPanel *m_pSSPanel; 63 | COCRPanel *m_pOCRPanel; 64 | 65 | bool m_WasInited; 66 | CMainFrame *m_pMF; 67 | CTabArt *m_pTabArt; 68 | 69 | public: 70 | void Init(); 71 | void RefreshData(); 72 | }; 73 | 74 | 75 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/ScrollBar.cpp: -------------------------------------------------------------------------------- 1 | //ScrollBar.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #include "ScrollBar.h" 18 | #include "IPAlgorithms.h" 19 | 20 | BEGIN_EVENT_TABLE(CScrollBar, wxPanel) 21 | EVT_PAINT(CScrollBar::OnPaint) 22 | EVT_LEFT_DOWN(CScrollBar::OnLButtonDown) 23 | EVT_LEFT_UP(CScrollBar::OnLButtonUp) 24 | EVT_MOTION(CScrollBar::OnMouseMove) 25 | END_EVENT_TABLE() 26 | 27 | CScrollBar::CScrollBar( wxWindow *parent, 28 | wxWindowID id, 29 | const wxPoint& pos, 30 | const wxSize& size) 31 | :wxPanel( parent, id, pos, size, 32 | wxTAB_TRAVERSAL | wxBORDER, 33 | "panel" ) 34 | { 35 | m_pParent = parent; 36 | 37 | m_SBLA = wxImage(g_app_dir + "/bitmaps/sb_la.bmp"); 38 | m_SBRA = wxImage(g_app_dir + "/bitmaps/sb_ra.bmp"); 39 | m_SBLC = wxImage(g_app_dir + "/bitmaps/sb_lc.bmp"); 40 | m_SBRC = wxImage(g_app_dir + "/bitmaps/sb_rc.bmp"); 41 | m_SBT = wxImage(g_app_dir + "/bitmaps/sb_t.bmp"); 42 | 43 | m_rcSBT.x = -1; 44 | m_rcSBT.y = -1; 45 | 46 | m_rcSBLA.height = -1; 47 | 48 | m_min_pos = 0; 49 | m_max_pos = 100; 50 | m_pos = m_min_pos; 51 | m_range = m_max_pos - m_min_pos; 52 | 53 | this->SetCursor( wxCursor( wxCURSOR_HAND ) ); 54 | 55 | m_ld = false; 56 | } 57 | 58 | CScrollBar::~CScrollBar() 59 | { 60 | } 61 | 62 | void CScrollBar::OnPaint(wxPaintEvent& WXUNUSED(event)) 63 | { 64 | int w, h, aw, ah, new_aw, new_ah, tw, th, new_tw, new_th, tx, prev_tx = m_rcSBT.x, dr; 65 | wxBitmap newSBLA, newSBRA, newSBT, newSBLC, newSBRC; 66 | bool isRes = false; 67 | this->GetClientSize(&w, &h); 68 | 69 | //wxPaintDC dc( this ); 70 | wxBitmap bmp(w, h); 71 | wxMemoryDC dc(bmp); 72 | 73 | aw = m_SBLA.GetWidth(); 74 | ah = m_SBLA.GetHeight(); 75 | 76 | new_ah = h; 77 | new_aw = (int)((double)(aw*new_ah)/(double)ah); 78 | 79 | tw = m_SBT.GetWidth(); 80 | th = m_SBT.GetHeight(); 81 | 82 | new_th = h; 83 | new_tw = (int)((double)(tw*new_th)/(double)th); 84 | 85 | dr = w - 2*new_aw - new_tw; 86 | tx = new_aw + ((double)dr/(double)m_range)*(double)(m_pos - m_min_pos); 87 | 88 | m_rcSBLA.x = 0; 89 | m_rcSBLA.y = 0; 90 | m_rcSBLA.width = new_aw; 91 | m_rcSBLA.height = new_ah; 92 | 93 | m_rcSBRA.x = w-new_aw; 94 | m_rcSBRA.y = 0; 95 | m_rcSBRA.width = new_aw; 96 | m_rcSBRA.height = new_ah; 97 | 98 | m_rcSBLC.x = new_aw; 99 | m_rcSBLC.y = 0; 100 | m_rcSBLC.width = tx-new_aw; 101 | m_rcSBLC.height = h; 102 | 103 | m_rcSBT.x = tx; 104 | m_rcSBT.y = 0; 105 | m_rcSBT.width = new_tw; 106 | m_rcSBT.height = new_th; 107 | 108 | m_rcSBRC.x = tx+new_tw; 109 | m_rcSBRC.y = 0; 110 | m_rcSBRC.width = w-(tx+new_tw)-new_aw; 111 | m_rcSBRC.height = h; 112 | 113 | newSBLA = wxBitmap(m_SBLA.Scale(m_rcSBLA.width, m_rcSBLA.height, wxIMAGE_QUALITY_HIGH)); 114 | if (m_rcSBLC.width > 0) 115 | { 116 | newSBLC = wxBitmap(m_SBLC.Scale(m_rcSBLC.width, m_rcSBLC.height, wxIMAGE_QUALITY_HIGH)); 117 | } 118 | newSBT = wxBitmap(m_SBT.Scale(m_rcSBT.width, m_rcSBT.height, wxIMAGE_QUALITY_HIGH)); 119 | if (m_rcSBRC.width > 0) 120 | { 121 | newSBRC = wxBitmap(m_SBRC.Scale(m_rcSBRC.width, m_rcSBRC.height, wxIMAGE_QUALITY_HIGH)); 122 | } 123 | newSBRA = wxBitmap(m_SBRA.Scale(m_rcSBRA.width, m_rcSBRA.height, wxIMAGE_QUALITY_HIGH)); 124 | 125 | dc.DrawBitmap(newSBLA, m_rcSBLA.x, m_rcSBLA.y); 126 | if (m_rcSBLC.width > 0) 127 | { 128 | dc.DrawBitmap(newSBLC, m_rcSBLC.x, m_rcSBLC.y); 129 | } 130 | dc.DrawBitmap(newSBT, m_rcSBT.x, m_rcSBT.y); 131 | if (m_rcSBRC.width > 0) 132 | { 133 | dc.DrawBitmap(newSBRC, m_rcSBRC.x, m_rcSBRC.y); 134 | } 135 | dc.DrawBitmap(newSBRA, m_rcSBRA.x, m_rcSBRA.y); 136 | 137 | wxBufferedPaintDC bpdc(this, bmp); 138 | } 139 | 140 | void CScrollBar::SetScrollRange(int min_pos, int max_pos) 141 | { 142 | double dpos = (double)(m_pos-m_min_pos)/(double)(m_range); 143 | 144 | m_min_pos = min_pos; 145 | m_max_pos = max_pos; 146 | m_range = m_max_pos - m_min_pos; 147 | 148 | m_pos = m_min_pos + (int)((double)m_range*(double)dpos); 149 | 150 | this->Refresh(false); 151 | } 152 | 153 | void CScrollBar::SetScrollPos(int pos) 154 | { 155 | if (pos <= m_min_pos) 156 | { 157 | m_pos = m_min_pos; 158 | } 159 | else if (pos <= m_max_pos) 160 | { 161 | m_pos = pos; 162 | } 163 | else 164 | { 165 | m_pos = m_max_pos; 166 | } 167 | 168 | this->Refresh(false); 169 | } 170 | 171 | void CScrollBar::OnLButtonDown( wxMouseEvent& event ) 172 | { 173 | int x = event.m_x, y = event.m_y, w, h; 174 | this->GetClientSize(&w, &h); 175 | 176 | m_pParent->SetFocus(); 177 | 178 | if ( m_rcSBT.Contains(x, y) || m_rcSBLC.Contains(x, y) || m_rcSBRC.Contains(x, y) ) 179 | { 180 | m_ld = true; 181 | this->CaptureMouse(); 182 | 183 | m_pos = m_min_pos + ((double)(x - m_rcSBT.width/2 - m_rcSBLA.width)/(double)(w - 2*m_rcSBLA.width - m_rcSBT.width))*(double)m_range; 184 | if (m_pos < m_min_pos) m_pos = m_min_pos; 185 | if (m_pos > m_max_pos) m_pos = m_max_pos; 186 | 187 | this->Refresh(false); 188 | 189 | wxScrollEvent scroll_event(wxEVT_SCROLL_THUMBTRACK, 0, m_pos, 0); 190 | wxEvtHandler *handler = m_pParent->GetEventHandler(); 191 | handler->ProcessEvent(scroll_event); 192 | } 193 | else if ( m_rcSBLA.Contains(x, y) ) 194 | { 195 | this->ScrollLeft(); 196 | } 197 | else if ( m_rcSBRA.Contains(x, y) ) 198 | { 199 | this->ScrollRight(); 200 | } 201 | } 202 | 203 | void CScrollBar::OnLButtonUp( wxMouseEvent& event ) 204 | { 205 | if ( m_ld ) 206 | { 207 | m_ld = false; 208 | this->ReleaseMouse(); 209 | } 210 | } 211 | 212 | void CScrollBar::OnMouseMove( wxMouseEvent& event ) 213 | { 214 | if ( m_ld ) 215 | { 216 | int x = event.m_x, y = event.m_y, w, h; 217 | this->GetClientSize(&w, &h); 218 | 219 | m_pos = m_min_pos + ((double)(x - m_rcSBT.width/2 - m_rcSBLA.width)/(double)(w - 2*m_rcSBLA.width - m_rcSBT.width))*(double)m_range; 220 | if (m_pos < m_min_pos) m_pos = m_min_pos; 221 | if (m_pos > m_max_pos) m_pos = m_max_pos; 222 | 223 | this->Refresh(false); 224 | 225 | wxScrollEvent scroll_event(wxEVT_SCROLL_THUMBTRACK, 0, m_pos, 0); 226 | wxEvtHandler *handler = m_pParent->GetEventHandler(); 227 | handler->ProcessEvent(scroll_event); 228 | } 229 | } 230 | 231 | void CScrollBar::ScrollLeft() 232 | { 233 | if (m_pos > m_min_pos) 234 | { 235 | m_pos--; 236 | this->Refresh(false); 237 | 238 | wxScrollEvent scroll_event(wxEVT_SCROLL_THUMBTRACK, 0, -2, 0); 239 | wxEvtHandler *handler = m_pParent->GetEventHandler(); 240 | handler->ProcessEvent(scroll_event); 241 | } 242 | } 243 | 244 | void CScrollBar::ScrollRight() 245 | { 246 | if (m_pos < m_max_pos) 247 | { 248 | m_pos++; 249 | this->Refresh(false); 250 | 251 | wxScrollEvent scroll_event(wxEVT_SCROLL_THUMBTRACK, 0, -1, 0); 252 | wxEvtHandler *handler = m_pParent->GetEventHandler(); 253 | handler->ProcessEvent(scroll_event); 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/ScrollBar.h: -------------------------------------------------------------------------------- 1 | //ScrollBar.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | class CScrollBar : public wxPanel 26 | { 27 | public: 28 | CScrollBar( wxWindow *parent, 29 | wxWindowID id = wxID_ANY, 30 | const wxPoint& pos = wxDefaultPosition, 31 | const wxSize& size = wxDefaultSize ); 32 | ~CScrollBar(); 33 | 34 | public: 35 | wxWindow *m_pParent; 36 | 37 | wxBitmap m_Bmp; 38 | wxBitmap m_PrevBmp; 39 | wxImage m_SBLA; 40 | wxImage m_SBRA; 41 | wxImage m_SBLC; 42 | wxImage m_SBRC; 43 | wxImage m_SBT; 44 | 45 | wxRect m_rcSBLA; 46 | wxRect m_rcSBRA; 47 | wxRect m_rcSBT; 48 | wxRect m_rcSBLC; 49 | wxRect m_rcSBRC; 50 | 51 | bool m_ld; 52 | 53 | int m_pos; 54 | int m_min_pos; 55 | int m_max_pos; 56 | int m_range; 57 | 58 | int GetScrollPos() { return m_pos; } 59 | void SetScrollPos (int pos); 60 | void SetScrollRange (int min_pos, int max_pos); 61 | 62 | void OnPaint( wxPaintEvent &event ); 63 | void OnLButtonDown( wxMouseEvent& event ); 64 | void OnLButtonUp( wxMouseEvent& event ); 65 | void OnMouseMove( wxMouseEvent& event ); 66 | 67 | void ScrollLeft(); 68 | void ScrollRight(); 69 | 70 | private: 71 | DECLARE_EVENT_TABLE() 72 | }; 73 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/SearchPanel.h: -------------------------------------------------------------------------------- 1 | //SearchPanel.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include "SSOWnd.h" 24 | #include "Button.h" 25 | #include "StaticText.h" 26 | #include "TextCtrl.h" 27 | #include "MyResource.h" 28 | 29 | class CMainFrame; 30 | class CSSOWnd; 31 | 32 | extern int g_IsSearching; 33 | extern int g_IsClose; 34 | 35 | void ThreadSearchSubtitles(); 36 | 37 | class CSearchPanel : public wxPanel, public CControl 38 | { 39 | public: 40 | CSearchPanel(CSSOWnd* pParent); 41 | ~CSearchPanel(); 42 | 43 | std::mutex m_rs_mutex; 44 | 45 | CButton *m_pClear; 46 | CButton *m_pRun; 47 | 48 | wxPanel *m_pP1; 49 | 50 | CStaticText *m_plblBT1; 51 | CTextCtrl *m_plblBTA1; 52 | CStaticText *m_plblBT2; 53 | CTextCtrl *m_plblBTA2; 54 | 55 | CSSOWnd *m_pParent; 56 | 57 | CMainFrame *m_pMF; 58 | 59 | std::thread m_SearchThread; 60 | 61 | void Init(); 62 | 63 | public: 64 | //HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); 65 | void OnBnClickedRun(wxCommandEvent& event); 66 | void OnBnClickedClear(wxCommandEvent& event); 67 | void OnTimeTextEnter(wxCommandEvent& evt); 68 | void ThreadSearchSubtitlesEnd(wxCommandEvent& event); 69 | void UpdateSize() override; 70 | void RefreshData() override; 71 | 72 | private: 73 | DECLARE_EVENT_TABLE() 74 | }; 75 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/SeparatingLine.cpp: -------------------------------------------------------------------------------- 1 | //SeparatingLine.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #include "SeparatingLine.h" 18 | 19 | BEGIN_EVENT_TABLE(CSeparatingLine, wxWindow) 20 | EVT_PAINT(CSeparatingLine::OnPaint) 21 | EVT_ERASE_BACKGROUND(CSeparatingLine::OnEraseBackground) 22 | EVT_LEFT_DOWN(CSeparatingLine::OnLButtonDown) 23 | EVT_LEFT_UP(CSeparatingLine::OnLButtonUp) 24 | EVT_MOTION(CSeparatingLine::OnMouseMove) 25 | EVT_MOUSE_CAPTURE_LOST(CSeparatingLine::OnMouseCaptureLost) 26 | END_EVENT_TABLE() 27 | 28 | CSeparatingLine::CSeparatingLine(wxWindow* parent, int w, int h, int sw, int sh, int minpos, int maxpos, int offset, int orientation, wxColour main_colour, wxColour border_colour, wxWindowID id) 29 | : wxWindow( parent, id, wxDefaultPosition, wxDefaultSize, 30 | wxTRANSPARENT_WINDOW | wxWANTS_CHARS 31 | ) 32 | { 33 | m_bDown = false; 34 | m_pParent = parent; 35 | m_main_colour = main_colour; 36 | m_border_colour = border_colour; 37 | 38 | m_w = w; 39 | m_h = h; 40 | 41 | m_sw = sw; 42 | m_sh = sh; 43 | 44 | m_min = minpos; 45 | m_max = maxpos; 46 | 47 | m_offset = offset; 48 | 49 | m_orientation = orientation; 50 | 51 | m_pos = 0; 52 | m_pos_min = 0; 53 | m_pos_max = 1; 54 | 55 | wxRect rc; 56 | 57 | if (m_orientation == 0) 58 | { 59 | this->SetCursor( wxCursor( wxCURSOR_SIZENS ) ); 60 | 61 | rc.x = m_offset-m_sw; 62 | rc.y = m_min-m_h/2-m_sh; 63 | rc.width = m_w+2*m_sw; 64 | rc.height = m_h+2*m_sh; 65 | } 66 | else 67 | { 68 | this->SetCursor( wxCursor( wxCURSOR_SIZEWE ) ); 69 | 70 | rc.x = m_min-m_w/2-m_sw; 71 | rc.y = m_offset-m_sh; 72 | rc.width = m_w+2*m_sw; 73 | rc.height = m_h+2*m_sh; 74 | } 75 | 76 | CreateNewRgn(); 77 | 78 | //this->Raise(); 79 | 80 | UpdateSL(); 81 | } 82 | 83 | CSeparatingLine::~CSeparatingLine() 84 | { 85 | } 86 | 87 | void CSeparatingLine::CreateNewRgn() 88 | { 89 | wxPoint ps[20]; 90 | int i = 0; 91 | 92 | if (m_orientation == 0) 93 | { 94 | ps[i].x = 0; 95 | ps[i].y = 0; 96 | i++; 97 | 98 | ps[i].x = m_sw; 99 | ps[i].y = m_sh; 100 | i++; 101 | 102 | ps[i].x = m_w+m_sw; 103 | ps[i].y = m_sh; 104 | i++; 105 | 106 | ps[i].x = m_w+2*m_sw; 107 | ps[i].y = 0; 108 | i++; 109 | 110 | ps[i].x = m_w+m_sw+1; 111 | ps[i].y = m_sh+(m_h+1)/2+1; 112 | i++; 113 | 114 | ps[i].x = m_w+m_sw+1; 115 | ps[i].y = m_sh+(m_h+1)/2-1; 116 | i++; 117 | 118 | ps[i].x = m_w+2*m_sw; 119 | ps[i].y = m_sh+m_h+m_sh; 120 | i++; 121 | 122 | ps[i].x = m_w+m_sw; 123 | ps[i].y = m_sh+m_h; 124 | i++; 125 | 126 | ps[i].x = m_sw; 127 | ps[i].y = m_sh+m_h; 128 | i++; 129 | 130 | ps[i].x = 0; 131 | ps[i].y = m_sh+m_h+m_sh; 132 | i++; 133 | 134 | ps[i].x = m_sw-1; 135 | ps[i].y = m_sh+(m_h+1)/2-1; 136 | i++; 137 | 138 | ps[i].x = m_sw-1; 139 | ps[i].y = m_sh+(m_h+1)/2+1; 140 | i++; 141 | } 142 | else 143 | { 144 | ps[i].x = 0; 145 | ps[i].y = 0; 146 | i++; 147 | 148 | ps[i].x = m_sw+1+(m_w+1)/2; 149 | ps[i].y = m_sh-1; 150 | i++; 151 | 152 | ps[i].x = m_sw-1+(m_w+1)/2; 153 | ps[i].y = m_sh-1; 154 | i++; 155 | 156 | ps[i].x = m_w+2*m_sw; 157 | ps[i].y = 0; 158 | i++; 159 | 160 | ps[i].x = m_w+m_sw; 161 | ps[i].y = m_sh; 162 | i++; 163 | 164 | ps[i].x = m_w+m_sw; 165 | ps[i].y = m_sh+m_h; 166 | i++; 167 | 168 | ps[i].x = m_w+2*m_sw; 169 | ps[i].y = m_h+2*m_sh; 170 | i++; 171 | 172 | ps[i].x = m_sw-1+(m_w+1)/2; 173 | ps[i].y = m_h+m_sh+1; 174 | i++; 175 | 176 | ps[i].x = m_sw+1+(m_w+1)/2; 177 | ps[i].y = m_h+m_sh+1; 178 | i++; 179 | 180 | ps[i].x = 0; 181 | ps[i].y = m_h+2*m_sh; 182 | i++; 183 | 184 | ps[i].x = m_sw; 185 | ps[i].y = m_h+m_sh; 186 | i++; 187 | 188 | ps[i].x = m_sw; 189 | ps[i].y = m_sh; 190 | i++; 191 | } 192 | 193 | m_rgn = wxRegion( (size_t)i, ps, wxWINDING_RULE ); 194 | 195 | //this->SetShape(m_rgn); 196 | 197 | m_old_w = m_w; 198 | m_old_h = m_h; 199 | } 200 | 201 | void CSeparatingLine::OnLButtonDown( wxMouseEvent& event ) 202 | { 203 | m_bDown = true; 204 | this->CaptureMouse(); 205 | } 206 | 207 | void CSeparatingLine::OnLButtonUp( wxMouseEvent& event ) 208 | { 209 | if (m_bDown == true) 210 | { 211 | m_bDown = false; 212 | this->ReleaseMouse(); 213 | 214 | this->Refresh(true); 215 | } 216 | } 217 | 218 | void CSeparatingLine::OnMouseCaptureLost(wxMouseCaptureLostEvent& event) 219 | { 220 | if (m_bDown == true) 221 | { 222 | m_bDown = false; 223 | } 224 | } 225 | 226 | void CSeparatingLine::OnMouseMove( wxMouseEvent& event ) 227 | { 228 | if (m_bDown == true) 229 | { 230 | wxPoint pt = this->GetPosition(); 231 | wxSize border = this->GetWindowBorderSize(); 232 | 233 | MoveSL( wxPoint(pt.x + border.GetWidth() + event.m_x, pt.y + border.GetHeight() + event.m_y) ); 234 | } 235 | } 236 | 237 | void CSeparatingLine::MoveSL(wxPoint pt) 238 | { 239 | int val; 240 | 241 | if (m_orientation == 0) 242 | val = pt.y; 243 | else 244 | val = pt.x; 245 | 246 | if (val > m_max) 247 | { 248 | m_pos = 1; 249 | } 250 | else 251 | { 252 | if (val < m_min) 253 | { 254 | m_pos = 0; 255 | } 256 | else 257 | { 258 | m_pos = (double)(val-m_min)/(double)(m_max-m_min); 259 | } 260 | } 261 | 262 | if (m_pos < m_pos_min) m_pos = m_pos_min; 263 | if (m_pos > m_pos_max) m_pos = m_pos_max; 264 | 265 | UpdateSL(); 266 | } 267 | 268 | double CSeparatingLine::CalculateCurPos() 269 | { 270 | wxRect rc; 271 | int val; 272 | double res; 273 | 274 | rc = this->GetRect(); 275 | 276 | if (m_orientation == 0) 277 | { 278 | val = rc.y+m_h/2+m_sh; 279 | } 280 | else 281 | { 282 | val = rc.x+m_w/2+m_sw; 283 | } 284 | 285 | res = (double)(val-m_min)/(double)(m_max-m_min); 286 | 287 | return res; 288 | } 289 | 290 | int CSeparatingLine::GetCurPos() 291 | { 292 | wxRect rc; 293 | int res; 294 | 295 | rc = this->GetRect(); 296 | 297 | if (m_orientation == 0) 298 | { 299 | res = rc.y+m_h/2+m_sh; 300 | } 301 | else 302 | { 303 | res = rc.x+m_w/2+m_sw; 304 | } 305 | 306 | return res; 307 | } 308 | 309 | void CSeparatingLine::UpdateSL() 310 | { 311 | wxRect rc; 312 | int pos; 313 | 314 | pos = m_min+(int)(m_pos*(double)(m_max-m_min)); 315 | 316 | if ( (m_w != m_old_w) || (m_h != m_old_h) ) 317 | { 318 | CreateNewRgn(); 319 | } 320 | 321 | if (m_orientation == 0) 322 | { 323 | rc.x = m_offset-m_sw; 324 | rc.y = pos-m_h/2-m_sh; 325 | rc.width = m_w+2*m_sw; 326 | rc.height = m_h+2*m_sh; 327 | } 328 | else 329 | { 330 | rc.x = pos-m_w/2-m_sw; 331 | rc.y = m_offset-m_sh; 332 | rc.width = m_w+2*m_sw; 333 | rc.height = m_h+2*m_sh; 334 | } 335 | 336 | 337 | #ifdef WIN32 338 | this->Show(false); 339 | #endif 340 | 341 | this->SetSize(rc); 342 | 343 | #ifdef WIN32 344 | this->Show(true); 345 | this->Raise(); 346 | #endif 347 | 348 | this->Refresh(true); 349 | } 350 | 351 | void CSeparatingLine::OnPaint(wxPaintEvent& WXUNUSED(event)) 352 | { 353 | wxPaintDC dc(this); 354 | int w, h; 355 | 356 | this->GetClientSize(&w, &h); 357 | 358 | wxBrush borderBrush(m_border_colour); 359 | wxBrush mainBrush(m_main_colour); 360 | 361 | dc.SetBackgroundMode(wxTRANSPARENT); 362 | dc.DestroyClippingRegion(); 363 | dc.SetClippingRegion(m_rgn); 364 | 365 | dc.SetBrush(borderBrush); 366 | dc.DrawRectangle(0, 0, w, h); 367 | 368 | dc.SetBrush(mainBrush); 369 | if (m_orientation == 0) 370 | { 371 | dc.DrawRectangle(m_sw, m_sh, m_w, m_h); 372 | } 373 | else 374 | { 375 | dc.DrawRectangle(m_sw, m_sh, m_w, m_h); 376 | } 377 | } 378 | 379 | void CSeparatingLine::OnEraseBackground(wxEraseEvent &event) 380 | { 381 | wxDC *pdc = event.GetDC(); 382 | 383 | int w, h; 384 | 385 | this->GetClientSize(&w, &h); 386 | 387 | wxBrush borderBrush(m_border_colour); 388 | wxBrush mainBrush(m_main_colour); 389 | 390 | pdc->SetBackgroundMode(wxTRANSPARENT); 391 | pdc->DestroyClippingRegion(); 392 | pdc->SetClippingRegion(m_rgn); 393 | 394 | pdc->SetBrush(borderBrush); 395 | pdc->DrawRectangle(0, 0, w, h); 396 | 397 | pdc->SetBrush(mainBrush); 398 | if (m_orientation == 0) 399 | { 400 | pdc->DrawRectangle(m_sw, m_sh, m_w, m_h); 401 | } 402 | else 403 | { 404 | pdc->DrawRectangle(m_sw, m_sh, m_w, m_h); 405 | } 406 | } -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/SeparatingLine.h: -------------------------------------------------------------------------------- 1 | //SeparatingLine.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include 21 | //#include 22 | //#include 23 | //#include 24 | //#include 25 | //#include 26 | 27 | class CSeparatingLine : public wxWindow 28 | { 29 | public: 30 | CSeparatingLine(wxWindow *parent, int w, int h, int sw, int sh, int minpos, int maxpos, int offset, int orientation, wxColour main_colour, wxColour border_colour, wxWindowID id = wxID_ANY); 31 | ~CSeparatingLine(); 32 | 33 | int m_w; 34 | int m_old_w; 35 | int m_h; 36 | int m_old_h; 37 | 38 | int m_sw; 39 | int m_sh; 40 | 41 | int m_min; 42 | int m_max; 43 | int m_offset; 44 | 45 | int m_orientation; // 0 horizontal, 1 vertical 46 | 47 | double m_pos; 48 | double m_pos_min; 49 | double m_pos_max; 50 | 51 | wxWindow* m_pParent; 52 | wxRegion m_rgn; 53 | wxColour m_main_colour; 54 | wxColour m_border_colour; 55 | 56 | bool m_bDown; 57 | 58 | public: 59 | void CreateNewRgn(); 60 | void MoveSL(wxPoint pt); 61 | void UpdateSL(); 62 | double CalculateCurPos(); 63 | int GetCurPos(); 64 | 65 | public: 66 | void OnPaint( wxPaintEvent &event ); 67 | void OnEraseBackground(wxEraseEvent &event); 68 | void OnLButtonDown( wxMouseEvent& event ); 69 | void OnLButtonUp( wxMouseEvent& event ); 70 | void OnMouseMove( wxMouseEvent& event ); 71 | void OnMouseCaptureLost(wxMouseCaptureLostEvent& event); 72 | 73 | private: 74 | DECLARE_EVENT_TABLE() 75 | }; -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/SettingsPanel.h: -------------------------------------------------------------------------------- 1 | //SettingsPanel.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include "SSOWnd.h" 19 | #include "StaticText.h" 20 | #include "DataGrid.h" 21 | #include "DataTypes.h" 22 | #include "TextCtrl.h" 23 | #include "Button.h" 24 | #include "BitmapButton.h" 25 | #include "StaticBox.h" 26 | #include 27 | #include 28 | 29 | class CMainFrame; 30 | class CSSOWnd; 31 | 32 | class CSettingsPanel : public wxPanel, public CControl 33 | { 34 | public: 35 | CSettingsPanel(CSSOWnd* pParent); 36 | ~CSettingsPanel(); 37 | 38 | CDataGrid *m_pOI; 39 | CDataGrid *m_pOIM; 40 | 41 | CButton *m_pTest; 42 | CStaticBox *m_pGB1; 43 | CStaticBox *m_pGB2; 44 | CStaticBox *m_pGB3; 45 | wxPanel *m_pP2; 46 | 47 | CBitmapButton *m_pLeft; 48 | CBitmapButton *m_pRight; 49 | CStaticText *m_plblIF; 50 | 51 | CStaticText* m_plblGSFN; 52 | CStaticText* m_pGSFN; 53 | 54 | CStaticText* m_plblPixelColor; 55 | CTextCtrl* m_pPixelColorRGB; 56 | CTextCtrl* m_pPixelColorLab; 57 | CStaticText* m_pPixelColorExample; 58 | 59 | wxColour m_PixelColorExample; 60 | 61 | int m_cn; 62 | 63 | int m_W = 0; 64 | int m_H = 0; 65 | int m_w = 0; 66 | int m_h = 0; 67 | int m_xmin = 0; 68 | int m_ymin = 0; 69 | int m_xmax = 0; 70 | int m_ymax = 0; 71 | 72 | //HCURSOR m_hCursor; 73 | 74 | CSSOWnd *m_pParent; 75 | 76 | CMainFrame *m_pMF; 77 | 78 | custom_buffer> m_ImF; 79 | 80 | void Init(); 81 | 82 | public: 83 | void OnBnClickedTest(wxCommandEvent& event); 84 | void OnBnClickedLeft(wxCommandEvent& event); 85 | void OnBnClickedRight(wxCommandEvent& event); 86 | void ViewCurImF(); 87 | void UpdateSize() override; 88 | void RefreshData() override; 89 | 90 | private: 91 | DECLARE_EVENT_TABLE() 92 | }; 93 | 94 | 95 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/StaticBox.cpp: -------------------------------------------------------------------------------- 1 | //StaticBox.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include "StaticBox.h" 19 | #include 20 | 21 | CStaticBox::CStaticBox(wxWindow* parent, wxWindowID id, 22 | const wxString& label, 23 | const wxPoint& pos, 24 | const wxSize& size, 25 | long style, 26 | const wxString& name) : wxStaticBox(parent, id, label, pos, size, style, name) 27 | { 28 | m_pParent = parent; 29 | m_p_label = &label; 30 | } 31 | 32 | void CStaticBox::SetFont(wxFont& font) 33 | { 34 | m_pFont = &font; 35 | wxStaticBox::SetFont(*m_pFont); 36 | } 37 | 38 | void CStaticBox::SetTextColour(wxColour& colour) 39 | { 40 | m_pTextColour = &colour; 41 | wxStaticBox::SetForegroundColour(*m_pTextColour); 42 | } 43 | 44 | void CStaticBox::SetBackgroundColour(wxColour& colour) 45 | { 46 | m_pBackgroundColour = &colour; 47 | wxStaticBox::SetBackgroundColour(*m_pBackgroundColour); 48 | } 49 | 50 | void CStaticBox::SetLabel(const wxString& label) 51 | { 52 | m_p_label = &label; 53 | wxStaticBox::SetLabel(*m_p_label); 54 | } 55 | 56 | void CStaticBox::SetMinSize(wxSize& size) 57 | { 58 | m_min_size = size; 59 | } 60 | 61 | void CStaticBox::RefreshData() 62 | { 63 | wxStaticBox::SetLabel(*m_p_label); 64 | if (m_pFont) wxStaticBox::SetFont(*m_pFont); 65 | if (m_pTextColour) wxStaticBox::SetForegroundColour(*m_pTextColour); 66 | if (m_pBackgroundColour) wxStaticBox::SetBackgroundColour(*m_pBackgroundColour); 67 | } 68 | 69 | void CStaticBox::UpdateSize() 70 | { 71 | wxSizer* p_own_sizer = GetSizer(); 72 | wxSizer* p_parent_sizer = GetContainingSizer(); 73 | 74 | if (p_own_sizer && p_parent_sizer) 75 | { 76 | wxSize best_size = p_own_sizer->GetMinSize(); 77 | wxSize cur_size = GetSize(); 78 | wxSize cur_client_size = GetClientSize(); 79 | best_size.x += cur_size.x - cur_client_size.x + 20; 80 | best_size.y += cur_size.y - cur_client_size.y + 20; 81 | 82 | p_parent_sizer->SetItemMinSize(this, best_size); 83 | p_parent_sizer->Layout(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/StaticBox.h: -------------------------------------------------------------------------------- 1 | //StaticBox.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include "Control.h" 20 | 21 | class CStaticBox : public wxStaticBox, public CControl 22 | { 23 | public: 24 | CStaticBox(wxWindow* parent, wxWindowID id, 25 | const wxString& label, 26 | const wxPoint& pos = wxDefaultPosition, 27 | const wxSize& size = wxDefaultSize, 28 | long style = 0, 29 | const wxString& name = wxStaticBoxNameStr); 30 | CStaticBox(wxWindow* parent, wxWindowID id, 31 | const wxString&& label, 32 | const wxPoint& pos = wxDefaultPosition, 33 | const wxSize& size = wxDefaultSize, 34 | long style = 0, 35 | const wxString& name = wxStaticBoxNameStr) = delete; 36 | 37 | void RefreshData(); 38 | void SetFont(wxFont& font); 39 | void SetTextColour(wxColour& colour); 40 | void SetBackgroundColour(wxColour& colour); 41 | void SetLabel(const wxString& label); 42 | void SetLabel(const wxString&& label) = delete; 43 | void SetMinSize(wxSize& size); 44 | void UpdateSize(); 45 | 46 | private: 47 | wxSize m_min_size; 48 | wxWindow* m_pParent; 49 | wxFont* m_pFont = NULL; 50 | wxColour* m_pTextColour = NULL; 51 | wxColour* m_pBackgroundColour = NULL; 52 | const wxString* m_p_label; 53 | }; 54 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/StaticText.cpp: -------------------------------------------------------------------------------- 1 | //StaticText.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #include "StaticText.h" 18 | #include 19 | #include 20 | 21 | BEGIN_EVENT_TABLE(CStaticText, wxPanel) 22 | EVT_SIZE(CStaticText::OnSize) 23 | END_EVENT_TABLE() 24 | 25 | CStaticText::CStaticText( wxWindow* parent, 26 | const wxString& label, 27 | wxWindowID id, 28 | long text_style, 29 | long panel_style, 30 | const wxPoint& pos, 31 | const wxSize& size) 32 | :wxPanel( parent, id, pos, size, panel_style, wxT("")) 33 | { 34 | m_pParent = parent; 35 | m_p_label = &label; 36 | 37 | m_pST = new wxStaticText(this, wxID_ANY, *m_p_label, wxDefaultPosition, wxDefaultSize, text_style, wxStaticTextNameStr); 38 | 39 | m_text_style = text_style; 40 | } 41 | 42 | CStaticText::~CStaticText() 43 | { 44 | } 45 | 46 | void CStaticText::SetFont(wxFont& font) 47 | { 48 | m_pFont = &font; 49 | m_pST->SetFont(*m_pFont); 50 | 51 | wxSizeEvent event; 52 | OnSize(event); 53 | } 54 | 55 | void CStaticText::SetTextColour(wxColour& colour) 56 | { 57 | m_pTextColour = &colour; 58 | m_pST->SetForegroundColour(*m_pTextColour); 59 | } 60 | 61 | void CStaticText::SetBackgroundColour(wxColour& colour) 62 | { 63 | m_pBackgroundColour = &colour; 64 | wxPanel::SetBackgroundColour(*m_pBackgroundColour); 65 | m_pST->SetBackgroundColour(*m_pBackgroundColour); 66 | } 67 | 68 | wxSize CStaticText::GetOptimalSize(int add_gap) 69 | { 70 | wxMemoryDC dc; 71 | if (m_pFont) dc.SetFont(*m_pFont); 72 | wxSize best_size = dc.GetMultiLineTextExtent(*m_p_label); 73 | wxSize cur_size = this->GetSize(); 74 | wxSize cur_client_size = this->GetClientSize(); 75 | wxSize opt_size = cur_size; 76 | best_size.x += cur_size.x - cur_client_size.x + add_gap; 77 | best_size.y += cur_size.y - cur_client_size.y + add_gap; 78 | 79 | if (m_allow_auto_set_min_width) 80 | { 81 | opt_size.x = std::max(best_size.x, m_min_size.x); 82 | } 83 | else 84 | { 85 | opt_size.x = 10; 86 | } 87 | 88 | opt_size.y = std::max(best_size.y, m_min_size.y); 89 | 90 | return opt_size; 91 | } 92 | 93 | void CStaticText::RefreshData() 94 | { 95 | m_pST->SetLabel(*m_p_label); 96 | 97 | if (m_pFont) m_pST->SetFont(*m_pFont); 98 | 99 | if (m_pTextColour) m_pST->SetForegroundColour(*m_pTextColour); 100 | 101 | if (m_pBackgroundColour) 102 | { 103 | wxPanel::SetBackgroundColour(*m_pBackgroundColour); 104 | m_pST->SetBackgroundColour(*m_pBackgroundColour); 105 | } 106 | 107 | wxSizer* pSizer = GetContainingSizer(); 108 | if (pSizer) 109 | { 110 | wxSize cur_size = this->GetSize(); 111 | wxSize opt_size = GetOptimalSize(); 112 | 113 | if (opt_size != cur_size) 114 | { 115 | pSizer->SetItemMinSize(this, opt_size); 116 | pSizer->Layout(); 117 | } 118 | } 119 | 120 | wxSizeEvent event; 121 | OnSize(event); 122 | } 123 | 124 | void CStaticText::SetMinSize(wxSize& size) 125 | { 126 | m_min_size = size; 127 | } 128 | 129 | void CStaticText::SetLabel(const wxString& label) 130 | { 131 | m_p_label = &label; 132 | m_pST->SetLabel(*m_p_label); 133 | wxSizeEvent event; 134 | OnSize(event); 135 | } 136 | 137 | void CStaticText::OnSize(wxSizeEvent& event) 138 | { 139 | int w, h, tw, th, x, y; 140 | 141 | this->GetClientSize(&w, &h); 142 | 143 | { 144 | wxMemoryDC dc; 145 | if (m_pFont) dc.SetFont(*m_pFont); 146 | wxSize st_best_size = dc.GetMultiLineTextExtent(*m_p_label); 147 | wxSize st_cur_size = m_pST->GetSize(); 148 | wxSize st_cur_client_size = m_pST->GetClientSize(); 149 | st_best_size.x += st_cur_size.x - st_cur_client_size.x; 150 | st_best_size.y += st_cur_size.y - st_cur_client_size.y; 151 | 152 | tw = st_best_size.x; 153 | th = st_best_size.y; 154 | } 155 | 156 | if ( m_text_style & wxALIGN_CENTER_HORIZONTAL ) 157 | { 158 | x = (w - tw)/2; 159 | } 160 | else if ( m_text_style & wxALIGN_RIGHT ) 161 | { 162 | x = w - tw; 163 | } 164 | else 165 | { 166 | x = 0; 167 | } 168 | 169 | if ( m_text_style & wxALIGN_CENTER_VERTICAL ) 170 | { 171 | y = (h - th)/2; 172 | } 173 | else if ( m_text_style & wxALIGN_BOTTOM ) 174 | { 175 | y = h - th; 176 | } 177 | else 178 | { 179 | y = 0; 180 | } 181 | 182 | m_pST->SetSize(x, y, tw, th); 183 | 184 | event.Skip(); 185 | } 186 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/StaticText.h: -------------------------------------------------------------------------------- 1 | //StaticText.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include "Control.h" 21 | 22 | class CStaticText : public wxPanel, public CControl 23 | { 24 | public: 25 | CStaticText(wxWindow* parent, 26 | const wxString& label, 27 | wxWindowID id = wxID_ANY, 28 | long text_style = wxALIGN_CENTER, 29 | long panel_style = wxTAB_TRAVERSAL | wxBORDER, 30 | const wxPoint& pos = wxDefaultPosition, 31 | const wxSize& size = wxDefaultSize); 32 | 33 | CStaticText(wxWindow* parent, 34 | const wxString&& label, 35 | wxWindowID id = wxID_ANY, 36 | long text_style = wxALIGN_CENTER, 37 | long panel_style = wxTAB_TRAVERSAL | wxBORDER, 38 | const wxPoint& pos = wxDefaultPosition, 39 | const wxSize& size = wxDefaultSize) = delete; 40 | 41 | ~CStaticText(); 42 | 43 | wxWindow *m_pParent; 44 | wxStaticText *m_pST; 45 | long m_text_style; 46 | bool m_allow_auto_set_min_width = true; 47 | 48 | public: 49 | void SetMinSize(wxSize& size); 50 | void SetFont(wxFont& font); 51 | void SetTextColour(wxColour& colour); 52 | void SetBackgroundColour(wxColour& colour); 53 | void SetLabel(const wxString& label); 54 | void SetLabel(const wxString&& label) = delete; 55 | void OnSize(wxSizeEvent& event); 56 | void RefreshData(); 57 | wxSize GetOptimalSize(int add_gap = 6); 58 | 59 | private: 60 | wxSize m_min_size; 61 | const wxString* m_p_label; 62 | wxFont *m_pFont = NULL; 63 | wxColour* m_pTextColour = NULL; 64 | wxColour* m_pBackgroundColour = NULL; 65 | DECLARE_EVENT_TABLE() 66 | }; 67 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/TextCtrl.cpp: -------------------------------------------------------------------------------- 1 | //TextCtrl.cpp// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include "TextCtrl.h" 19 | #include 20 | 21 | BEGIN_EVENT_TABLE(CTextCtrl, wxTextCtrl) 22 | EVT_TEXT(wxID_ANY, CTextCtrl::OnText) 23 | EVT_TEXT_ENTER(wxID_ANY, CTextCtrl::OnTextEnter) 24 | EVT_KILL_FOCUS(CTextCtrl::OnKillFocus) 25 | END_EVENT_TABLE() 26 | 27 | void CTextCtrl::OnKillFocus(wxFocusEvent& event) 28 | { 29 | if (m_re_expr.size() > 0) 30 | { 31 | wxString val = GetValue(); 32 | ValidateAndSaveData(val); 33 | } 34 | event.Skip(); 35 | } 36 | 37 | CTextCtrl::CTextCtrl(wxWindow* parent, 38 | wxWindowID id, 39 | wxString str_val, 40 | wxString re_expr, 41 | const wxPoint& pos, 42 | const wxSize& size, 43 | long style) : wxTextCtrl(parent, id, wxEmptyString, pos, size, style | wxTE_PROCESS_ENTER), m_re(re_expr) 44 | { 45 | m_pParent = parent; 46 | m_str_val = str_val; 47 | m_re_expr = re_expr; 48 | ChangeValue(str_val); 49 | } 50 | 51 | CTextCtrl::CTextCtrl(wxWindow* parent, 52 | wxWindowID id, 53 | wxString* p_str_val, 54 | wxString re_expr, 55 | const wxPoint& pos, 56 | const wxSize& size, 57 | long style) : wxTextCtrl(parent, id, wxEmptyString, pos, size, style | wxTE_PROCESS_ENTER), m_re(re_expr) 58 | { 59 | m_pParent = parent; 60 | m_p_str_val = p_str_val; 61 | m_re_expr = re_expr; 62 | ChangeValue(*m_p_str_val); 63 | } 64 | 65 | CTextCtrl::CTextCtrl(wxWindow* parent, 66 | wxWindowID id, 67 | double* p_f_val, 68 | const wxPoint& pos, 69 | const wxSize& size, 70 | long style) : wxTextCtrl(parent, id, wxEmptyString, pos, size, style) 71 | { 72 | m_pParent = parent; 73 | m_p_f_val = p_f_val; 74 | ChangeValue(wxString::Format(wxT("%f"), *m_p_f_val)); 75 | } 76 | 77 | void CTextCtrl::OnTextEnter(wxCommandEvent& evt) 78 | { 79 | if (m_re_expr.size() > 0) 80 | { 81 | wxString val = GetValue(); 82 | ValidateAndSaveData(val); 83 | } 84 | } 85 | 86 | bool CTextCtrl::ValidateAndSaveData(wxString val) 87 | { 88 | bool res = true; 89 | 90 | if (m_re_expr.size() > 0) 91 | { 92 | if (m_p_str_val) 93 | { 94 | if (m_re.Matches(val)) 95 | { 96 | *m_p_str_val = val; 97 | } 98 | else 99 | { 100 | res = false; 101 | ChangeValue(*m_p_str_val); 102 | } 103 | } 104 | else 105 | { 106 | if (m_re.Matches(val)) 107 | { 108 | m_str_val = val; 109 | } 110 | else 111 | { 112 | res = false; 113 | ChangeValue(m_str_val); 114 | } 115 | } 116 | } 117 | 118 | return res; 119 | } 120 | 121 | void CTextCtrl::OnText(wxCommandEvent& evt) 122 | { 123 | if (m_re_expr.size() == 0) 124 | { 125 | if (m_p_str_val) 126 | { 127 | *m_p_str_val = GetValue(); 128 | } 129 | else if (m_p_f_val) 130 | { 131 | double value; 132 | if (GetValue().ToDouble(&value)) 133 | { 134 | *m_p_f_val = value; 135 | } 136 | } 137 | } 138 | } 139 | 140 | void CTextCtrl::SetValue(const wxString& value) 141 | { 142 | if (ValidateAndSaveData(value)) 143 | { 144 | ChangeValue(value); 145 | } 146 | } 147 | 148 | void CTextCtrl::SetFont(wxFont& font) 149 | { 150 | m_pFont = &font; 151 | wxTextCtrl::SetFont(*m_pFont); 152 | } 153 | 154 | void CTextCtrl::SetTextColour(wxColour& colour) 155 | { 156 | m_pTextColour = &colour; 157 | wxTextCtrl::SetForegroundColour(*m_pTextColour); 158 | } 159 | 160 | void CTextCtrl::SetBackgroundColour(wxColour& colour) 161 | { 162 | m_pBackgroundColour = &colour; 163 | wxTextCtrl::SetBackgroundColour(*m_pBackgroundColour); 164 | } 165 | 166 | void CTextCtrl::SetMinSize(wxSize& size) 167 | { 168 | m_min_size = size; 169 | } 170 | 171 | void CTextCtrl::RefreshData() 172 | { 173 | if (m_pFont) wxTextCtrl::SetFont(*m_pFont); 174 | if (m_pTextColour) wxTextCtrl::SetForegroundColour(*m_pTextColour); 175 | if (m_pBackgroundColour) wxTextCtrl::SetBackgroundColour(*m_pBackgroundColour); 176 | 177 | if (m_p_str_val) 178 | { 179 | ChangeValue(*m_p_str_val); 180 | } 181 | else if (m_p_f_val) 182 | { 183 | ChangeValue(wxString::Format(wxT("%f"), *m_p_f_val)); 184 | } 185 | 186 | wxSizer* pSizer = GetContainingSizer(); 187 | if (pSizer) 188 | { 189 | wxSize text_size = this->GetTextExtent(this->GetValue()); 190 | wxSize best_size = this->GetSizeFromTextSize(text_size); 191 | wxSize cur_size = this->GetSize(); 192 | wxSize cur_client_size = this->GetClientSize(); 193 | wxSize opt_size; 194 | 195 | opt_size.x = std::max(best_size.x, m_min_size.x); 196 | opt_size.y = std::max(best_size.y, m_min_size.y); 197 | 198 | if (opt_size != cur_size) 199 | { 200 | pSizer->SetItemMinSize(this, opt_size); 201 | pSizer->Layout(); 202 | } 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/TextCtrl.h: -------------------------------------------------------------------------------- 1 | //TextCtrl.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include "Control.h" 21 | 22 | class CTextCtrl : public wxTextCtrl, public CControl 23 | { 24 | public: 25 | wxWindow* m_pParent; 26 | wxString* m_p_str_val = NULL; 27 | double* m_p_f_val = NULL; 28 | wxString m_str_val; 29 | wxString m_re_expr = wxString(); 30 | wxRegEx m_re; 31 | 32 | 33 | CTextCtrl(wxWindow* parent, 34 | wxWindowID id, 35 | wxString str_val = wxString(), 36 | wxString re_expr = wxString(), 37 | const wxPoint& pos = wxDefaultPosition, 38 | const wxSize& size = wxDefaultSize, 39 | long style = 0); 40 | 41 | CTextCtrl(wxWindow* parent, 42 | wxWindowID id, 43 | wxString* p_str_val, 44 | wxString re_expr = wxString(), 45 | const wxPoint& pos = wxDefaultPosition, 46 | const wxSize& size = wxDefaultSize, 47 | long style = 0); 48 | 49 | CTextCtrl(wxWindow* parent, 50 | wxWindowID id, 51 | double* p_f_val, 52 | const wxPoint& pos = wxDefaultPosition, 53 | const wxSize& size = wxDefaultSize, 54 | long style = 0); 55 | 56 | void OnText(wxCommandEvent& evt); 57 | void OnTextEnter(wxCommandEvent& evt); 58 | void OnKillFocus(wxFocusEvent& event); 59 | 60 | void SetValue(const wxString& value) wxOVERRIDE; 61 | 62 | bool ValidateAndSaveData(wxString val); 63 | void RefreshData(); 64 | 65 | void SetFont(wxFont& font); 66 | void SetTextColour(wxColour& colour); 67 | void SetBackgroundColour(wxColour& colour); 68 | void SetMinSize(wxSize& size); 69 | 70 | private: 71 | wxSize m_min_size; 72 | wxFont* m_pFont = NULL; 73 | wxColour* m_pTextColour = NULL; 74 | wxColour* m_pBackgroundColour = NULL; 75 | DECLARE_EVENT_TABLE() 76 | }; 77 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/VideoBox.h: -------------------------------------------------------------------------------- 1 | //VideoBox.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "MyResource.h" 23 | #include "MainFrm.h" 24 | #include "StaticText.h" 25 | #include "ScrollBar.h" 26 | #include "SeparatingLine.h" 27 | #include "ResizableWindow.h" 28 | #include "BitmapButton.h" 29 | #include "Control.h" 30 | 31 | class CVideoBox; 32 | class CVideoWindow; 33 | class CPopupHelpWindow; 34 | 35 | class CVideoWnd : public wxWindow 36 | { 37 | public: 38 | CVideoWnd(CVideoWindow *pVW); 39 | ~CVideoWnd(); 40 | 41 | CVideoWindow *m_pVW; 42 | CVideoBox *m_pVB; 43 | 44 | bool m_filter_image; 45 | 46 | public: 47 | void OnPaint( wxPaintEvent &event ); 48 | void OnEraseBackGround(wxEraseEvent& event); 49 | void OnLeftDown(wxMouseEvent& event); 50 | //void OnKeyUp(wxKeyEvent& event); 51 | bool CheckFilterImage(); 52 | void DrawImage(simple_buffer& ImBGR, const int w, const int h); 53 | 54 | private: 55 | DECLARE_EVENT_TABLE() 56 | }; 57 | 58 | class CVideoWindow: public wxPanel 59 | { 60 | public: 61 | CVideoWindow(CVideoBox *pVB); 62 | ~CVideoWindow(); 63 | 64 | CVideoWnd *m_pVideoWnd; 65 | CSeparatingLine *m_pHSL1; 66 | CSeparatingLine *m_pHSL2; 67 | CSeparatingLine *m_pVSL1; 68 | CSeparatingLine *m_pVSL2; 69 | 70 | bool m_WasInited; 71 | CVideoBox *m_pVB; 72 | 73 | public: 74 | void Init(); 75 | void Update(); 76 | void Refresh(bool eraseBackground = true, 77 | const wxRect* rect = (const wxRect*)NULL); 78 | 79 | public: 80 | void OnSize(wxSizeEvent& event); 81 | void OnPaint(wxPaintEvent &event); 82 | 83 | private: 84 | DECLARE_EVENT_TABLE() 85 | }; 86 | 87 | class CVideoBox : public CResizableWindow, public CControl 88 | { 89 | public: 90 | CVideoBox(CMainFrame* pMF); 91 | ~CVideoBox(); 92 | 93 | std::mutex m_mutex; 94 | 95 | CBitmapButton *m_pButtonRun; 96 | CBitmapButton *m_pButtonPause; 97 | CBitmapButton *m_pButtonStop; 98 | CStaticText *m_plblVB; 99 | CStaticText *m_plblTIME; 100 | CVideoWindow *m_pVBox; 101 | CScrollBar *m_pSB; 102 | 103 | wxImage m_tb_run_origImage; 104 | wxImage m_tb_pause_origImage; 105 | wxImage m_tb_stop_origImage; 106 | wxColour m_prevBackgroundColour; 107 | 108 | wxImage *m_pImage; 109 | wxFrame *m_pFullScreenWin; 110 | 111 | CMainFrame *m_pMF; 112 | bool m_WasInited; 113 | 114 | wxTimer m_timer; 115 | 116 | CPopupHelpWindow* m_pHW; 117 | 118 | public: 119 | void Init(); 120 | void ViewImage(simple_buffer &Im, int w, int h); 121 | void ViewGrayscaleImage(simple_buffer& Im, int w, int h); 122 | void ViewBGRImage(simple_buffer& ImBGR, int w, int h); 123 | void ClearScreen(); 124 | void UpdateSize() override; 125 | void RefreshData() override; 126 | 127 | public: 128 | void OnSize(wxSizeEvent& event); 129 | void OnBnClickedRun(wxCommandEvent& event); 130 | void OnBnClickedPause(wxCommandEvent& event); 131 | void OnBnClickedStop(wxCommandEvent& event); 132 | void OnKeyDown(wxKeyEvent& event); 133 | void OnKeyUp(wxKeyEvent& event); 134 | void OnMouseWheel(wxMouseEvent& event); 135 | void OnHScroll(wxScrollEvent& event); 136 | void OnTimer(wxTimerEvent& event); 137 | void OnRButtonDown(wxMouseEvent& event); 138 | 139 | private: 140 | std::mutex m_view_mutex; 141 | 142 | DECLARE_EVENT_TABLE() 143 | }; 144 | 145 | 146 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/VideoSubFinderWXW.h: -------------------------------------------------------------------------------- 1 | //VideoSubFinderWXW.h// 2 | ////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // Author: Simeon Kosnitsky // 5 | // skosnits@gmail.com // 6 | // // 7 | // License: // 8 | // This software is released into the public domain. You are free to use // 9 | // it in any way you like, except that you may not sell this source code. // 10 | // // 11 | // This software is provided "as is" with no expressed or implied warranty. // 12 | // I accept no liability for any damage or loss of business that this // 13 | // software may cause. // 14 | // // 15 | ////////////////////////////////////////////////////////////////////////////////// 16 | 17 | #pragma once 18 | 19 | #include "wx/wx.h" 20 | #include "DataTypes.h" 21 | #include "MainFrm.h" 22 | 23 | class CVideoSubFinderApp : public wxApp 24 | { 25 | public: 26 | ~CVideoSubFinderApp(); 27 | 28 | CMainFrame* m_pMainWnd; 29 | 30 | public: 31 | virtual bool OnInit(); 32 | virtual bool Initialize(int& argc, wxChar **argv); 33 | }; 34 | 35 | IMPLEMENT_APP(CVideoSubFinderApp) 36 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/VideoSubFinderWXW.rc: -------------------------------------------------------------------------------- 1 | vsf_ico ICON "videosubfinder.ico" 2 | #include "wx/msw/wx.rc" -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/VideoSubFinderWXW.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Version 16 3 | VisualStudioVersion = 16.0.30204.135 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoSubFinderWXW", "VideoSubFinderWXW.vcxproj", "{6786A82F-9596-45FF-9A44-7C1AF39EDE35}" 6 | ProjectSection(ProjectDependencies) = postProject 7 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8} = {E53D9010-1315-4693-B04E-D4F17BF5E2B8} 8 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5} = {3EBF793E-F25B-439F-A59E-EDFF159D4DF5} 9 | {B369FFAB-FB94-4F88-A374-39A604762D4B} = {B369FFAB-FB94-4F88-A374-39A604762D4B} 10 | EndProjectSection 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IPAlgorithms", "..\..\Components\IPAlgorithms\IPAlgorithms.vcxproj", "{BFE25C0A-EA0C-484D-B426-6D7511C9958B}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OCVVideo", "..\..\Components\OCVVideo\OCVVideo.vcxproj", "{B369FFAB-FB94-4F88-A374-39A604762D4B}" 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CUDAKernels", "..\..\Components\CUDAKernels\CUDAKernels.vcxproj", "{3EBF793E-F25B-439F-A59E-EDFF159D4DF5}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FFMPEGVideo", "..\..\Components\FFMPEGVideo\FFMPEGVideo.vcxproj", "{E53D9010-1315-4693-B04E-D4F17BF5E2B8}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Win32 = Debug|Win32 23 | Debug|x64 = Debug|x64 24 | Release|Win32 = Release|Win32 25 | Release|x64 = Release|x64 26 | ReleaseWithDebugInfo|Win32 = ReleaseWithDebugInfo|Win32 27 | ReleaseWithDebugInfo|x64 = ReleaseWithDebugInfo|x64 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.Debug|Win32.Build.0 = Debug|Win32 32 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.Debug|x64.ActiveCfg = Debug|x64 33 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.Debug|x64.Build.0 = Debug|x64 34 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.Release|Win32.ActiveCfg = Release|Win32 35 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.Release|Win32.Build.0 = Release|Win32 36 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.Release|x64.ActiveCfg = Release|x64 37 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.Release|x64.Build.0 = Release|x64 38 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.ReleaseWithDebugInfo|Win32.ActiveCfg = ReleaseWithDebugInfo|Win32 39 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.ReleaseWithDebugInfo|Win32.Build.0 = ReleaseWithDebugInfo|Win32 40 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.ReleaseWithDebugInfo|x64.ActiveCfg = ReleaseWithDebugInfo|x64 41 | {6786A82F-9596-45FF-9A44-7C1AF39EDE35}.ReleaseWithDebugInfo|x64.Build.0 = ReleaseWithDebugInfo|x64 42 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.Debug|Win32.ActiveCfg = Debug|Win32 43 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.Debug|Win32.Build.0 = Debug|Win32 44 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.Debug|x64.ActiveCfg = Debug|x64 45 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.Debug|x64.Build.0 = Debug|x64 46 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.Release|Win32.ActiveCfg = Release|Win32 47 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.Release|Win32.Build.0 = Release|Win32 48 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.Release|x64.ActiveCfg = Release|x64 49 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.Release|x64.Build.0 = Release|x64 50 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.ReleaseWithDebugInfo|Win32.ActiveCfg = ReleaseWithDebugInfo|Win32 51 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.ReleaseWithDebugInfo|Win32.Build.0 = ReleaseWithDebugInfo|Win32 52 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.ReleaseWithDebugInfo|x64.ActiveCfg = ReleaseWithDebugInfo|x64 53 | {BFE25C0A-EA0C-484D-B426-6D7511C9958B}.ReleaseWithDebugInfo|x64.Build.0 = ReleaseWithDebugInfo|x64 54 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.Debug|Win32.ActiveCfg = Debug|Win32 55 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.Debug|Win32.Build.0 = Debug|Win32 56 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.Debug|x64.ActiveCfg = Debug|x64 57 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.Debug|x64.Build.0 = Debug|x64 58 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.Release|Win32.ActiveCfg = Release|Win32 59 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.Release|Win32.Build.0 = Release|Win32 60 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.Release|x64.ActiveCfg = Release|x64 61 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.Release|x64.Build.0 = Release|x64 62 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.ReleaseWithDebugInfo|Win32.ActiveCfg = ReleaseWithDebugInfo|Win32 63 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.ReleaseWithDebugInfo|Win32.Build.0 = ReleaseWithDebugInfo|Win32 64 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.ReleaseWithDebugInfo|x64.ActiveCfg = ReleaseWithDebugInfo|x64 65 | {B369FFAB-FB94-4F88-A374-39A604762D4B}.ReleaseWithDebugInfo|x64.Build.0 = ReleaseWithDebugInfo|x64 66 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.Debug|Win32.ActiveCfg = Debug|x64 67 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.Debug|x64.ActiveCfg = Debug|x64 68 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.Debug|x64.Build.0 = Debug|x64 69 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.Release|Win32.ActiveCfg = Release|Win32 70 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.Release|x64.ActiveCfg = Release|x64 71 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.Release|x64.Build.0 = Release|x64 72 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.ReleaseWithDebugInfo|Win32.ActiveCfg = ReleaseWithDebugInfo|Win32 73 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.ReleaseWithDebugInfo|x64.ActiveCfg = ReleaseWithDebugInfo|x64 74 | {3EBF793E-F25B-439F-A59E-EDFF159D4DF5}.ReleaseWithDebugInfo|x64.Build.0 = ReleaseWithDebugInfo|x64 75 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.Debug|Win32.ActiveCfg = Debug|Win32 76 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.Debug|Win32.Build.0 = Debug|Win32 77 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.Debug|x64.ActiveCfg = Debug|x64 78 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.Debug|x64.Build.0 = Debug|x64 79 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.Release|Win32.ActiveCfg = Release|Win32 80 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.Release|Win32.Build.0 = Release|Win32 81 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.Release|x64.ActiveCfg = Release|x64 82 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.Release|x64.Build.0 = Release|x64 83 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.ReleaseWithDebugInfo|Win32.ActiveCfg = ReleaseWithDebugInfo|Win32 84 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.ReleaseWithDebugInfo|Win32.Build.0 = ReleaseWithDebugInfo|Win32 85 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.ReleaseWithDebugInfo|x64.ActiveCfg = ReleaseWithDebugInfo|x64 86 | {E53D9010-1315-4693-B04E-D4F17BF5E2B8}.ReleaseWithDebugInfo|x64.Build.0 = ReleaseWithDebugInfo|x64 87 | EndGlobalSection 88 | GlobalSection(SolutionProperties) = preSolution 89 | HideSolutionNode = FALSE 90 | EndGlobalSection 91 | GlobalSection(ExtensibilityGlobals) = postSolution 92 | SolutionGuid = {14CAA284-EF5C-4ABF-8564-1720A684E6E6} 93 | EndGlobalSection 94 | EndGlobal 95 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/VideoSubFinderWXW.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | Source Files 68 | 69 | 70 | Source Files 71 | 72 | 73 | Source Files 74 | 75 | 76 | Source Files 77 | 78 | 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | Header Files 124 | 125 | 126 | Header Files 127 | 128 | 129 | Header Files 130 | 131 | 132 | Header Files 133 | 134 | 135 | Header Files 136 | 137 | 138 | Header Files 139 | 140 | 141 | Header Files 142 | 143 | 144 | Header Files 145 | 146 | 147 | Header Files 148 | 149 | 150 | Header Files 151 | 152 | 153 | 154 | 155 | Resource Files 156 | 157 | 158 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/VideoSubFinderWXW.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(OutDir) 5 | WindowsLocalDebugger 6 | 7 | 8 | $(OutDir) 9 | WindowsLocalDebugger 10 | 11 | 12 | 13 | 14 | $(OutDir) 15 | WindowsLocalDebugger 16 | 17 | 18 | 19 | 20 | $(OutDir) 21 | WindowsLocalDebugger 22 | 23 | 24 | $(OutDir) 25 | WindowsLocalDebugger 26 | 27 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by VideoSubFinderWXW.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /Interfaces/VideoSubFinderWXW/videosubfinder.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SWHL/VideoSubFinder/d6ca256a87d2e3ab71c4544bc7379fb5475fcf09/Interfaces/VideoSubFinderWXW/videosubfinder.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 | ## VideoSubFinder ([Simeon Kosnitsky](https://sourceforge.net/u/skosnits/profile/)) 6 | 7 | ⚠️ This repo is automatically synchronized from [SourceForge VideoSubFinder](https://videosubfinder.sourceforge.io/). 8 | 9 | ### Introduction 10 | 11 | The main purpose of this program is to provide functionality for extract hardcoded subtitles (hardsub) from video. 12 | 13 | It provides two main features: 14 | 15 | 1. Autodetection of frames with hardcoded text (hardsub) on video with saving info about timing positions. 16 | 17 | 2. Generation of cleared from background text images, which allows with usage of OCR programs (like FineReader, Subtitle Edit, Google Drive) to generate complete subtitles with original text and timing. 18 | 19 | For working of this program on Windows will be required "Microsoft Visual C++ Redistributable runtime libraries 2022": 20 | 21 | 22 | Latest versions were built and tested on: 23 | 24 | - Windows 10 x64, 25 | - Ubuntu 20.04.5 LTS, 26 | - openSUSE Leap 15.4, 27 | - Arch Linux (EndeavourOS Cassini Nova 03-2023) 28 | 29 | For faster support in case of bug fixes please contact me in: 30 | 31 | 32 | ### For donate 33 | 34 | 35 | 36 | ### Features 37 | 38 | - video text detection 39 | - text extraction from video frames 40 | 41 | ### Best Way to Get Help 42 | 43 | Unfortunately, this project hasn't indicated the best way to get help, but that does not mean there are no ways to get support for VideoSubFinder. In cases like this, we recommend contacting the project admin(s) if possible, or asking for help on third-party support forums or social media. Many open source projects have their own dedicated website or social media profiles where users can get support. 44 | 45 | Check out the other support options below. 46 | 47 | ### Other Ways Of Getting Help 48 | 49 | Here are some other places where you can look for information about this project. 50 | 51 | ### Project Trackers 52 | 53 | [Bugs](https://sourceforge.net/p/videosubfinder/bugs/) 54 | 55 | ### Project Forums 56 | 57 | [Discussion](https://sourceforge.net/p/videosubfinder/discussion/) 58 | 59 | ### Project Samples 60 | 61 |
62 |   63 |   64 |   65 | 66 |
67 | -------------------------------------------------------------------------------- /Settings/general.cfg: -------------------------------------------------------------------------------- 1 | prefered_locale = eng 2 | vsf_is_maximized = 0 3 | vsf_x = -1 4 | vsf_y = -1 5 | vsf_w = -1 6 | vsf_h = -1 7 | process_affinity_mask = -1 8 | main_text_font = default 9 | main_text_font_bold = 0 10 | main_text_font_italic = 0 11 | main_text_font_underline = 0 12 | main_text_font_size = -1 13 | buttons_text_font = default 14 | buttons_text_font_bold = 1 15 | buttons_text_font_italic = 0 16 | buttons_text_font_underline = 0 17 | buttons_text_font_size = -1 18 | main_text_colour = 0,0,0 19 | main_text_ctls_background_colour = 255,255,255 20 | main_buttons_colour = 252,252,252 21 | main_buttons_colour_focused = 242,242,242 22 | main_buttons_colour_selected = 211,211,211 23 | main_buttons_border_colour = 196,196,196 24 | main_labels_background_colour = 127,255,0 25 | main_frame_background_colour = 171,171,171 26 | notebook_colour = 240,240,240 27 | notebook_panels_colour = 170,170,170 28 | grid_line_colour = 0,0,0 29 | grid_gropes_colour = 0,255,255 30 | grid_sub_gropes_colour = 255,215,0 31 | grid_debug_settings_colour = 200,200,200 32 | test_result_label_colour = 127,255,212 33 | video_image_box_background_colour = 125,125,125 34 | video_image_box_border_colour = 215,228,242 35 | video_image_box_title_colour = 255,255,225 36 | video_box_time_colour = 0,0,0 37 | video_box_time_text_colour = 255,255,255 38 | video_box_separating_line_colour = 255,255,255 39 | video_box_separating_line_border_colour = 0,0,0 40 | dont_delete_unrecognized_images1 = 0 41 | dont_delete_unrecognized_images2 = 1 42 | generate_cleared_text_images_on_test = 1 43 | dump_debug_images = 0 44 | dump_debug_second_filtration_images = 0 45 | clear_test_images_folder = 1 46 | show_transformed_images_only = 0 47 | use_ocl = 1 48 | use_cuda_gpu = 0 49 | use_filter_color = none 50 | use_outline_filter_color = none 51 | dL_color = 40 52 | dA_color = 30 53 | dB_color = 30 54 | combine_to_single_cluster = 0 55 | cuda_kmeans_initial_loop_iterations = 20 56 | cuda_kmeans_loop_iterations = 30 57 | cpu_kmeans_initial_loop_iterations = 20 58 | cpu_kmeans_loop_iterations = 30 59 | moderate_threshold_for_scaled_image = 0.25 60 | moderate_threshold = 0.25 61 | moderate_threshold_for_NEdges = 0.25 62 | segment_width = 8 63 | segment_height = 3 64 | minimum_segments_count = 2 65 | min_sum_color_diff = 0 66 | between_text_distace = 0.07 67 | text_centre_offset = 0.2 68 | image_scale_for_clear_image = 4 69 | use_ISA_images = 1 70 | use_ILA_images = 1 71 | use_ILA_images_for_getting_txt_symbols_areas = 0 72 | use_ILA_images_before_clear_txt_images_from_borders = 0 73 | use_gradient_images_for_clear_txt_images = 1 74 | clear_txt_images_by_main_color = 1 75 | use_ILA_images_for_clear_txt_images = 1 76 | min_points_number = 30 77 | min_points_density = 0.3 78 | min_symbol_height = 0.02 79 | min_symbol_density = 0.2 80 | min_NEdges_points_density = 0.2 81 | threads = -1 82 | ocr_threads = -1 83 | sub_frame_length = 8 84 | text_percent = 0.3 85 | min_text_len_in_percent = 0.022 86 | vedges_points_line_error = 0.3 87 | ila_points_line_error = 0.3 88 | video_contrast = 1 89 | video_gamma = 1 90 | clear_txt_folders = 1 91 | join_subs_and_correct_time = 1 92 | clear_image_logical = 0 93 | clean_rgb_images_after_run = 0 94 | min_sub_duration = 0 95 | def_string_for_empty_sub = [sub_duration] 96 | txt_dw = 5 97 | txt_dy = 5 98 | use_ISA_images_for_search_subtitles = 1 99 | use_ILA_images_for_search_subtitles = 1 100 | replace_ISA_by_filtered_version = 1 101 | max_dl_down = 20 102 | max_dl_up = 40 103 | remove_wide_symbols = 0 104 | hw_device = cpu 105 | filter_descr = none 106 | text_alignment = 0 107 | save_each_substring_separately = 0 108 | save_scaled_images = 1 109 | playback_sound = 0 110 | border_is_darker = 1 111 | extend_by_grey_color = 0 112 | allow_min_luminance = 100 113 | bottom_video_image_percent_end = 0 114 | top_video_image_percent_end = 0.3 115 | left_video_image_percent_end = 0 116 | right_video_image_percent_end = 1 117 | toolbar_bitmaps_transparent_colour = 192,192,192 118 | ocr_join_images_clear_dir = 1 119 | ocr_join_images_join_rgb_images = 0 120 | ocr_join_images_use_txt_images_data_for_join_rgb_images = 1 121 | ocr_join_images_split_line = [sub_id] 122 | ocr_join_images_split_line_font_size = -1 123 | ocr_join_images_split_line_font_bold = 1 124 | ocr_join_images_sub_id_format = [%d] 125 | ocr_join_images_sub_search_by_id_format = \[%d\](.*?)\[\d+\] 126 | ocr_join_images_scale = 1 127 | ocr_join_images_max_number = 50 --------------------------------------------------------------------------------