@@ -187,14 +187,19 @@ protected function createBaseDir($directory, OutputInterface $output)
187
187
}
188
188
189
189
190
+ /**
191
+ * 编译安装opencv
192
+ * @author hihozhou
193
+ *
194
+ * @param $directory
195
+ */
190
196
public function buildOpenCV ($ directory )
191
197
{
192
198
//编译安装
193
199
$ commands = [
194
200
'cd opencv ' ,
195
201
'mkdir build ' ,
196
202
'cd build ' ,
197
- 'pwd ' ,
198
203
'cmake -D CMAKE_BUILD_TYPE=RELEASE \
199
204
-D CMAKE_INSTALL_PREFIX=/usr/local \
200
205
-D WITH_TBB=ON \
@@ -211,7 +216,8 @@ public function buildOpenCV($directory)
211
216
-D OPENCV_GENERATE_PKGCONFIG=ON \
212
217
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..\
213
218
&& make\
214
- && sudo make install '
219
+ && sudo make install ' ,
220
+ 'sh -c \'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf \''
215
221
216
222
];
217
223
$ process = new Process (implode (' && ' , $ commands ), $ directory , null , null , null );
@@ -223,6 +229,22 @@ public function buildOpenCV($directory)
223
229
}
224
230
}
225
231
232
+ protected function buildPHPOpenCV ($ directory )
233
+ {
234
+ $ phpOpencvUrl = 'https://github.com/hihozhou/php-opencv.git ' ;
235
+ $ command = "git clone {$ phpOpencvUrl } --branch master --depth 1 " ;
236
+ $ process = new Process ($ command , $ directory , null , null , null );
237
+ $ process ->setTty (Process::isTtySupported ());//检查TTY支持
238
+ try {
239
+ $ process ->mustRun ();
240
+
241
+ //
242
+
243
+ } catch (\Exception $ e ) {
244
+ throw new RuntimeException ('Aborting. ' );
245
+ }
246
+ }
247
+
226
248
/**
227
249
* Execute the command.
228
250
*
@@ -247,7 +269,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
247
269
248
270
//编译扩展
249
271
$ this ->buildOpenCV ($ directory );
250
-
272
+ //编译phpopencv扩展
273
+ $ this ->buildPHPOpenCV ($ directory );
251
274
252
275
$ output ->writeln ('<comment>Application ready! Build something amazing.</comment> ' );
253
276
}
0 commit comments