55<!-- START doctoc generated TOC please keep comment here to allow auto update -->
66<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
77
8- - [ Prepare] ( #prepare )
98- [ Prerequisites] ( #prerequisites )
9+ - [[ Ubuntu, Debian] Install needed packages:] ( #ubuntu-debian-install-needed-packages )
10+ - [[ Fedora] Install needed packages:] ( #fedora-install-needed-packages )
1011- [ Build System Environment] ( #build-system-environment )
1112- [ Install freetype and harfbuzz] ( #install-freetype-and-harfbuzz )
13+ - [[ Ubuntu, Debian] Install needed packages:] ( #ubuntu-debian-install-needed-packages-1 )
14+ - [[ Fedora] Install needed packages:] ( #fedora-install-needed-packages-1 )
15+ - [ Download the source code] ( #download-the-source-code )
1216- [ Build] ( #build )
13- - [ Change directory to the ** build directory** ] ( #change-directory-to-the-build-directory )
14- - [ Download the source code] ( #download-the-source-code )
15- - [ Create the ** opencv_lua-contrib-custom** rockspec] ( #create-the-opencv_lua-contrib-custom-rockspec )
16- - [ Change the package name to ** opencv_lua-contrib-custom** ] ( #change-the-package-name-to-opencv_lua-contrib-custom )
17- - [ Add our custom build variables in the build.variables] ( #add-our-custom-build-variables-in-the-buildvariables )
18- - [ Make the ** opencv_lua-contrib-custom** -scm-1.rockspec rockspec] ( #make-the-opencv_lua-contrib-custom-scm-1rockspec-rockspec )
19- - [ Pack the prebuilt binary on the ** server directory** ] ( #pack-the-prebuilt-binary-on-the-server-directory )
2017- [ Testing our custom prebuilt binary] ( #testing-our-custom-prebuilt-binary )
21- - [ Prepare] ( #prepare-1 )
18+ - [ Prepare] ( #prepare )
2219 - [ Initialize our test project and install our custom prebuilt binary] ( #initialize-our-test-project-and-install-our-custom-prebuilt-binary )
2320 - [ Create a file with an UTF-16 name] ( #create-a-file-with-an-utf-16-name )
2421 - [ Download the Microsoft JhengHei font family] ( #download-the-microsoft-jhenghei-font-family )
@@ -32,116 +29,69 @@ Here we will build a custom opencv with the folling modifications:
3229 - Add the freetype module.
3330
3431The procedure has been tested on :
35- - [ Windows WSL] ( https://learn.microsoft.com/en-us/windows/wsl/install ) with [ Ubuntu 22.04 (Jammy Jellyfish)] ( https://releases.ubuntu.com/jammy/ )
36- - [ Windows WSL] ( https://learn.microsoft.com/en-us/windows/wsl/install ) with [ LinuxmintWSL2)] ( https://github.com/sileshn/LinuxmintWSL2 )
32+ - [ Ubuntu 22.04 (Jammy Jellyfish)] ( https://releases.ubuntu.com/jammy/ )
3733
38- ## Prepare
34+ ## Prerequisites
3935
36+ - Install [ CMake >= 3.25] ( https://cmake.org/download/ )
4037 - Install [ LuaRocks] ( https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix )
38+ - Install [ Ninja] ( https://ninja-build.org/ )
4139 - Install [ NodeJS] ( https://nodejs.org/en/download/current )
42- - Install needed packages ` sudo snap install cmake --classic && sudo apt -y install build-essential git python3-pip python3-venv python-is-python3 ninja-build unzip zip qtbase5-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-dev libreadline-dev `
43-
44- ## Prerequisites
4540
46- I assume you already have an [ Lua] ( https://www.lua.org/start.html ) or [ LuaJIT] ( https://luajit.org/ ) installation.
47- I assume you have already installed [ LuaRocks] ( https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix )
48- If not, you can install LuaJIT and LuaRocks by executing the following commands
41+ ### [ Ubuntu, Debian] Install needed packages:
42+ ``` sh
43+ sudo apt install -y build-essential curl git libavcodec-dev libavformat-dev libdc1394-dev \
44+ libjpeg-dev libpng-dev libreadline-dev libswscale-dev libtbb-dev \
45+ ninja-build pkg-config python3-pip python3-venv qtbase5-dev unzip wget zip
46+ ```
4947
48+ ### [ Fedora] Install needed packages:
5049``` sh
51- mkdir -p " $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de"
52- git clone --depth 1 --branch v0.0.4 https://github.com/smbape/lua-opencv.git $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/src
53- cd " $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/src"
54- ./build.sh " -DLua_VERSION=luajit-2.1" --target luajit --install
55- ./build.sh " -DLua_VERSION=luajit-2.1" --target luarocks
50+ sudo yum install -y build-essential curl git libavcodec-devel libavformat-devel libdc1394-devel \
51+ libjpeg-devel libpng-devel libreadline-devel libswscale-devel make patch libtbb-devel \
52+ ninja-build pkg-config python3-pip python3-venv qtbase5-devel unzip wget zip
5653```
5754
5855## Build System Environment
5956
60- We will name our LuaRocks pakcage ** opencv_lua-contrib- custom** in order to avoir conflict with the original package name
57+ We will name our LuaRocks pakcage ** opencv_lua-custom** in order to avoir conflict with the original package name
6158
6259In this example, we will use the following directories:
63- - The ** Lua binary directory** is _ $HOME/.vs/ lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/src /out/install/Linux-GCC-Release/bin_
64- - The ** LuaRocks binary directory** is _ $HOME/.vs/ lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/src /out/build.luaonly/Linux-GCC-Release/luarocks/luarocks-prefix/src/luarocks-build/bin_
65- - The ** build directory** is _ $HOME/.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de /opencv-lua-custom/build_
66- - The ** server directory** is _ $HOME/.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de /opencv-lua-custom/server_
67- - The ** test directory** is _ $HOME/.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de /opencv-lua-custom/test_
60+ - The ** Lua binary directory** is _ $/io/opencv- lua-custom/build/out/prepublish/luajit-2.1/opencv_lua-custom/ /out/install/Linux-GCC-Release/bin_
61+ - The ** LuaRocks binary directory** is _ /io/opencv- lua-custom/build/out/prepublish/luajit-2.1/opencv_lua-custom /out/build.luaonly/Linux-GCC-Release/luarocks/luarocks-prefix/src/luarocks-build/bin_
62+ - The ** build directory** is _ /io /opencv-lua-custom/build_
63+ - The ** server directory** is _ /io /opencv-lua-custom/server_
64+ - The ** test directory** is _ /io /opencv-lua-custom/test_
6865
6966## Install freetype and harfbuzz
7067
7168Freetype and harfbuzz are needed to build the OpenCV freetype contrib module
7269
70+ ### [ Ubuntu, Debian] Install needed packages:
7371``` sh
74- sudo apt -y install libfreetype-dev libharfbuzz-dev
75- ```
76-
77- ## Build
78-
79- Add your ** Lua binary directory** to the PATH environment variable
80- ``` sh
81- export PATH=" $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/src/out/install/Linux-GCC-Release/bin:$PATH "
82- ```
83-
84- Add your ** LuaRocks binary directory** to the PATH environment variable
85- ``` sh
86- export PATH=" $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/src/out/build.luaonly/Linux-GCC-Release/luarocks/luarocks-prefix/src/luarocks-build/bin:$PATH "
72+ sudo apt install -y libfreetype-dev libharfbuzz-dev
8773```
8874
89- ### Change directory to the ** build directory**
90-
91- ``` sh
92- mkdir -p " $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/opencv-lua-custom/build" && \
93- cd " $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/opencv-lua-custom/build"
94- ```
95-
96- ### Download the source code
97-
75+ ### [ Fedora] Install needed packages:
9876``` sh
99- git clone --depth 1 --branch v0.0.4 https://github.com/smbape/lua-opencv.git && \
100- cd lua-opencv
77+ sudo apt install -y freetype-devel harfbuzz-devel
10178```
10279
103- ### Create the ** opencv_lua-contrib-custom ** rockspec
80+ ## Download the source code
10481
10582``` sh
106- cp luarocks/opencv_lua-scm-1.rockspec opencv_lua-contrib-custom-scm-1.rockspec
83+ git clone --depth 1 --branch v0.0.4 https://github.com/smbape/lua-opencv.git /io/opencv-lua-custom/build && \
84+ cd /io/opencv-lua-custom/build && \
85+ npm ci
10786```
10887
109- Edit The ** opencv_lua-contrib-custom** -scm-1.rockspec file:
110-
111- #### Change the package name to ** opencv_lua-contrib-custom**
112-
113- ``` sh
114- sed -e ' s/package = "opencv_lua"/package = "opencv_lua-contrib-custom"/' -i opencv_lua-contrib-custom-scm-1.rockspec
115- ```
116-
117- #### Add our custom build variables in the build.variables
118-
119- ``` sh
120- sed -e ' s/LUA_INCDIR = "\$(LUA_INCDIR)",/LUA_INCDIR = "\$(LUA_INCDIR)",\n BUILD_contrib = "ON",\n WITH_FREETYPE = "ON",/' -i opencv_lua-contrib-custom-scm-1.rockspec
121- ```
122-
123- The command above adds the following variables
124-
125- ``` lua
126- BUILD_contrib = " ON" ,
127- WITH_FREETYPE = " ON" ,
128- ```
129-
130- ### Make the ** opencv_lua-contrib-custom** -scm-1.rockspec rockspec
131-
132- ``` sh
133- cd luarocks && \
134- luarocks --lua-version " 5.1" --lua-dir " $( dirname " $( dirname " $( command -v luajit) " ) " ) " init --lua-versions " 5.1,5.2,5.3,5.4" && \
135- luarocks config --scope project cmake_generator Ninja && \
136- luarocks config --scope project cmake_build_args -- -j$(( $(nproc) - 2 > 1 ? $(nproc) - 2 : 1 )) && \
137- cd .. && \
138- ./luarocks/luarocks make opencv_lua-contrib-custom-scm-1.rockspec
139- ```
140-
141- ## Pack the prebuilt binary on the ** server directory**
88+ ## Build
14289
14390``` sh
144- LUAROCKS_SERVER=" $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/opencv-lua-custom/server" DIST_VERSION=1 ROCKSPEC=opencv_lua-contrib-custom-scm-1.rockspec node --trace-uncaught scripts/pack.js
91+ # --lua-versions luajit-2.1,5.1,5.2,5.3,5.4
92+ node scripts/prepublish.js --pack --server=" /d/opencv-lua-custom/server" --lua-versions luajit-2.1 --name=opencv_lua-custom \
93+ -DBUILD_contrib=ON \
94+ -DWITH_FREETYPE=ON
14595```
14696
14797## Testing our custom prebuilt binary
@@ -152,34 +102,34 @@ Open a new terminal.
152102
153103Add your ** Lua binary directory** to the PATH environment variable
154104``` sh
155- export PATH=" $HOME /.vs/ lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/src /out/install/Linux-GCC-Release/bin:$PATH "
105+ export PATH=" /io/opencv- lua-custom/build/out/prepublish/luajit-2.1/opencv_lua-custom /out/install/Linux-GCC-Release/bin:$PATH "
156106```
157107
158108Add your ** LuaRocks binary directory** to the PATH environment variable
159109``` sh
160- export PATH=" $HOME /.vs/ lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/src /out/build.luaonly/Linux-GCC-Release/luarocks/luarocks-prefix/src/luarocks-build/bin:$PATH "
110+ export PATH=" /io/opencv- lua-custom/build/out/prepublish/luajit-2.1/opencv_lua-custom /out/build.luaonly/Linux-GCC-Release/luarocks/luarocks-prefix/src/luarocks-build/bin:$PATH "
161111```
162112
163113### Initialize our test project and install our custom prebuilt binary
164114
165115``` sh
166- git clone --depth 1 --branch 4.10.0 https://github.com/opencv/opencv_extra.git " $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de /opencv-lua-custom/opencv_extra" && \
167- mkdir " $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de /opencv-lua-custom/test" && \
168- cd " $HOME /.vs/lua-opencv/53b58a2f-f3e5-480b-8803-dc266ac326de /opencv-lua-custom/test" && \
116+ git clone --depth 1 --branch 4.10.0 https://github.com/opencv/opencv_extra.git " /io /opencv-lua-custom/opencv_extra" && \
117+ mkdir " /io /opencv-lua-custom/test" && \
118+ cd " /io /opencv-lua-custom/test" && \
169119luarocks --lua-version " 5.1" --lua-dir " $( dirname " $( dirname " $( command -v luajit) " ) " ) " init --lua-versions " 5.1,5.2,5.3,5.4" && \
170- luarocks install --server=" $HOME /.vs/lua- opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/opencv- lua-custom/server" opencv_lua-contrib -custom
120+ luarocks install --server=" /io/ opencv- lua-custom/server" opencv_lua-custom
171121```
172122
173123### Create a file with an UTF-16 name
174124
175125``` sh
176- cp -f " $HOME /.vs/lua- opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/opencv- lua-custom/opencv_extra/testdata/cv/qrcode/multiple/6_qrcodes.png" " $HOME /.vs/lua- opencv/53b58a2f-f3e5-480b-8803-dc266ac326de/opencv- lua-custom/opencv_extra/testdata/cv/qrcode/multiple/6_二维码.png"
126+ cp -f /io/ opencv- lua-custom/opencv_extra/testdata/cv/qrcode/multiple/6_qrcodes.png /io/ opencv- lua-custom/opencv_extra/testdata/cv/qrcode/multiple/6_二维码.png
177127```
178128
179129### Download the [ Microsoft JhengHei] ( https://learn.microsoft.com/sr-cyrl-rs/typography/font-list/microsoft-jhenghei ) font family
180130
181131``` sh
182- wget " https://github.com/taveevut/Windows-10-Fonts-Default/raw/master/msjh.ttc" -O msjh.ttc
132+ wget https://github.com/taveevut/Windows-10-Fonts-Default/raw/master/msjh.ttc -O msjh.ttc
183133```
184134
185135### Execute a test script
@@ -230,7 +180,7 @@ if retval then
230180 end
231181end
232182
233- cv .imshow (" 二维码 " , img_rgb )
183+ cv .imshow (" qrcodes " , img_rgb )
234184cv .waitKey ()
235185cv .destroyAllWindows ()
236186```
@@ -248,5 +198,5 @@ Alternatively, If you want an installation over http/s, upload the contents of *
248198For example, if you uploaded it into http://example.com/binary-rock/ , you can install the prebuilt binary with
249199
250200``` sh
251- luarocks install --server=http://example.com/binary-rock opencv_lua-contrib- custom
201+ luarocks install --server=http://example.com/binary-rock opencv_lua-custom
252202```
0 commit comments