Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 62e5ace

Browse files
committed
clone phpopencv
1 parent 64878a5 commit 62e5ace

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

‎src/InstallCommand.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,19 @@ protected function createBaseDir($directory, OutputInterface $output)
187187
}
188188

189189

190+
/**
191+
* 编译安装opencv
192+
* @author hihozhou
193+
*
194+
* @param $directory
195+
*/
190196
public function buildOpenCV($directory)
191197
{
192198
//编译安装
193199
$commands = [
194200
'cd opencv',
195201
'mkdir build',
196202
'cd build',
197-
'pwd',
198203
'cmake -D CMAKE_BUILD_TYPE=RELEASE \
199204
-D CMAKE_INSTALL_PREFIX=/usr/local \
200205
-D WITH_TBB=ON \
@@ -211,7 +216,8 @@ public function buildOpenCV($directory)
211216
-D OPENCV_GENERATE_PKGCONFIG=ON \
212217
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..\
213218
&& make\
214-
&& sudo make install'
219+
&& sudo make install',
220+
'sh -c \'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf\''
215221

216222
];
217223
$process = new Process(implode(' && ', $commands), $directory, null, null, null);
@@ -223,6 +229,22 @@ public function buildOpenCV($directory)
223229
}
224230
}
225231

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+
226248
/**
227249
* Execute the command.
228250
*
@@ -247,7 +269,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
247269

248270
//编译扩展
249271
$this->buildOpenCV($directory);
250-
272+
//编译phpopencv扩展
273+
$this->buildPHPOpenCV($directory);
251274

252275
$output->writeln('<comment>Application ready! Build something amazing.</comment>');
253276
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /