-
Notifications
You must be signed in to change notification settings - Fork 1
/
edgeDemo.php
38 lines (29 loc) · 931 Bytes
/
edgeDemo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require __DIR__ . '/vendor/autoload.php';
$cv = new openCv\core();
$cv->namedwindow();
$capture = $cv->createCameraCapture();
if(!$cv->grabFrame($capture)){
echo 'Error no camera detected!';
return -1;
}
$img = $cv->queryFrame($capture);
$grayImg = $cv->createImage($img->width,$img->height,$img->depth,1);
$grayImg->origin = $img->origin;
$edgeImg = $cv->createImage($img->width, $img->height, $img->depth, 1);
$edgeImg->origin = $img->origin;
$keepProcessing = true;
$cv->grabFrame($capture);
while ($keepProcessing){
$Img = $cv->queryFrame($capture);
$cv->cvtColor($Img, $grayImg, $cv::CV_BGR2GRAY);
$cv->canny($grayImg, $edgeImg);
$cv->showImage($edgeImg, true);
$key = $cv->waitKey(40);
#if($key === 'x');{
# print("Keyboard exit requested : exiting now - bye!\n");
# $keepProcessing = false;
#}
$cv->grabFrame($capture);
}
$cv->destroyWindow($cv::WND_TITLE);