-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedgenImg_Based_recog.php
45 lines (38 loc) · 1.12 KB
/
edgenImg_Based_recog.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
39
40
41
42
43
44
45
<?php
require __DIR__ . '/vendor/autoload.php';
$imagesCollected = 0;
$recognitionStage = false;
$cv = new openCv\core();
$cv->init_legacy();
$cv->namedwindow();
$font = $cv->font();
$cv->initFont($font);
$capture = $cv->createCameraCapture();
if(!$cv->grabFrame($capture)){
echo 'Error no camera detected!';
return -1;
}
else{
$img = $cv->queryFrame($capture);
$grayImage = $cv->createImage($img->width, $img->height, $img->depth, 1);
$grayImage->origin = $img->origin;
while (true) {
$img = $cv->queryFrame($capture);
$cv->flip($img, null, 1);
if($img->nChannels > 1){
$cv->cvtColor($img, $grayImage, $cv::CV_BGR2GRAY);
}
else{
$grayImage = $img;
}
if(!$recognitionStage){
$cv->putText($img, 'Sample Collection', $cv->cvPoint(10, $img->height - 20), $font , $cv->cvRGB(0, 255, 0));
}
else{
$cv->putText($img, 'Recognition', $cv->cvPoint(10, $img->height-20), $font, $cv->cvRGB(0, 255, 0));
}
$cv->showImage($img, true);
$cv->waitKey(40);
}
}
$cv->destroyAllWindows();