update examples for working with blobFromImage as function instead of method
Esse commit está contido em:
@@ -9,10 +9,10 @@ $src = imread("images/cat.jpg"); // opencv loads image to matrix with BGR order
|
||||
$src = cvtColor($src, CV\COLOR_BGR2RGB); // convert BGR to RGB
|
||||
//var_export($src);
|
||||
|
||||
$blob = \CV\DNN\Net::blobFromImage($src, 0.017, new \CV\Size(224,224), new Scalar(103.94, 116.78, 123.68)); // convert image to 4 dimensions matrix
|
||||
$blob = \CV\DNN\blobFromImage($src, 0.017, new \CV\Size(224,224), new Scalar(103.94, 116.78, 123.68)); // convert image to 4 dimensions matrix
|
||||
//var_export($blob);
|
||||
|
||||
$net = \CV\DNN\Net::readNetFromCaffe('models/mobilenet/mobilenet_deploy.prototxt', 'models/mobilenet/mobilenet.caffemodel');
|
||||
$net = \CV\DNN\readNetFromCaffe('models/mobilenet/mobilenet_deploy.prototxt', 'models/mobilenet/mobilenet.caffemodel');
|
||||
|
||||
$net->setInput($blob, "");
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ equalizeHist($gray, $gray);
|
||||
|
||||
\CV\resize($src, $resised, new Size(300, 300));
|
||||
|
||||
$blob = \CV\DNN\Net::blobFromImage($resised, 1, new Size(300, 300), new Scalar(104, 177, 123));
|
||||
$blob = \CV\DNN\blobFromImage($resised, 1, new Size(300, 300), new Scalar(104, 177, 123));
|
||||
|
||||
$net = \CV\DNN\Net::readNetFromCaffe('models/ssd/res10_300x300_ssd_deploy.prototxt', 'models/ssd/res10_300x300_ssd_iter_140000.caffemodel');
|
||||
$net = \CV\DNN\readNetFromCaffe('models/ssd/res10_300x300_ssd_deploy.prototxt', 'models/ssd/res10_300x300_ssd_iter_140000.caffemodel');
|
||||
|
||||
$net->setInput($blob, "");
|
||||
|
||||
@@ -21,10 +21,10 @@ $r = $net->forward();
|
||||
|
||||
$scalar = new Scalar(0, 0, 255);
|
||||
for ($i = 0; $i < $r->shape[2]; $i++) {
|
||||
$confidence = $r->atIdx([0,0,$i,2], 1);
|
||||
$confidence = $r->atIdx([0,0,$i,2]);
|
||||
//var_export($confidence);echo "\n";
|
||||
if ($confidence > 0.5) {
|
||||
rectangle($src, $r->atIdx([0,0,$i,3], 1)*$src->cols, $r->atIdx([0,0,$i,4], 1)*$src->rows, $r->atIdx([0,0,$i,5], 1)*$src->cols, $r->atIdx([0,0,$i,6], 1)*$src->rows, $scalar, 3);
|
||||
rectangle($src, $r->atIdx([0,0,$i,3])*$src->cols, $r->atIdx([0,0,$i,4])*$src->rows, $r->atIdx([0,0,$i,5])*$src->cols, $r->atIdx([0,0,$i,6])*$src->rows, $scalar, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM ubuntu:17.10
|
||||
|
||||
RUN apt update && apt install -y wget pkg-config cmake git checkinstall
|
||||
|
||||
RUN echo 1
|
||||
|
||||
RUN git clone https://github.com/opencv/opencv_contrib.git && git clone https://github.com/opencv/opencv.git
|
||||
|
||||
RUN cd opencv_contrib && git checkout 3.4 && cd ../opencv && git checkout 3.4
|
||||
|
||||
RUN mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ../opencv && make -j4 && make install
|
||||
|
||||
RUN ldconfig
|
||||
|
||||
#build deb package:
|
||||
|
||||
RUN cd build && checkinstall --default --type debian --install=no --pkgname opencv --pkgversion "3.4" --pkglicense "3-clause BSD License" --pakdir ~ --maintainer "php-opencv" --addso --autodoinst make install
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM ubuntu:17.10
|
||||
|
||||
RUN apt update && apt install -y php-cli wget pkg-config cmake git php-cli php-dev checkinstall
|
||||
|
||||
RUN echo 1
|
||||
|
||||
RUN wget https://raw.githubusercontent.com/php-opencv/php-opencv-packages/master/opencv_3.4_amd64.deb && dpkg -i opencv_3.4_amd64.deb && rm opencv_3.4_amd64.deb
|
||||
|
||||
RUN git clone https://github.com/php-opencv/php-opencv.git
|
||||
|
||||
RUN cd php-opencv && phpize && ./configure --with-php-config=/usr/bin/php-config && make && make install
|
||||
|
||||
RUN echo "extension=opencv.so" > /etc/php/7.1/cli/conf.d/opencv.ini
|
||||
|
||||
#build deb package:
|
||||
|
||||
RUN cd php-opencv && checkinstall --default --type debian --install=no --pkgname php-opencv --pkgversion "7.1-3.4" --pkglicense "Apache 2.0" --pakdir ~ --maintainer "php-opencv" --addso --autodoinst make install
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt update && export DEBIAN_FRONTEND=noninteractive && apt install -y php-cli wget pkg-config cmake git php-cli php-dev checkinstall
|
||||
|
||||
RUN echo 1
|
||||
|
||||
RUN wget https://raw.githubusercontent.com/php-opencv/php-opencv-packages/master/opencv_3.4_amd64.deb && dpkg -i opencv_3.4_amd64.deb && rm opencv_3.4_amd64.deb
|
||||
|
||||
RUN git clone https://github.com/php-opencv/php-opencv.git
|
||||
|
||||
RUN cd php-opencv && phpize && ./configure --with-php-config=/usr/bin/php-config && make && make install
|
||||
|
||||
RUN echo "extension=opencv.so" > /etc/php/7.2/cli/conf.d/opencv.ini
|
||||
|
||||
#build deb package:
|
||||
|
||||
RUN cd php-opencv && checkinstall --default --type debian --install=no --pkgname php-opencv --pkgversion "7.2-3.4" --pkglicense "Apache 2.0" --pakdir ~ --maintainer "php-opencv" --addso --autodoinst make install
|
||||
+41
-23
@@ -180,9 +180,9 @@ class Mat {
|
||||
* @param array $idx
|
||||
* @param int $channel
|
||||
* @param null $value
|
||||
* @return int|null
|
||||
* @return Mat $mat
|
||||
*/
|
||||
public function atIdx(array $idx, int $channel, $value = null) {
|
||||
public function atIdx(array $idx, int $channel = 1, $value = null) {
|
||||
|
||||
}
|
||||
|
||||
@@ -991,27 +991,6 @@ use CV\Scalar;
|
||||
use CV\Size;
|
||||
|
||||
class Net {
|
||||
public static function blobFromImage(Mat $image, float $scalefactor = 1.0, Size $size = null, Scalar $mean = null, $swapRB = true, $crop = true) {
|
||||
return new Mat();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return Net
|
||||
*/
|
||||
public static function readNetFromTorch(string $filename) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $protoFilename
|
||||
* @param string $modelFilename
|
||||
* @return Net
|
||||
*/
|
||||
public static function readNetFromCaffe(string $protoFilename, $modelFilename) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Mat $blob
|
||||
* @param string $name
|
||||
@@ -1027,4 +1006,43 @@ class Net {
|
||||
public function forward() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Mat $image
|
||||
* @param float $scalefactor
|
||||
* @param Size $size
|
||||
* @param Scalar $mean
|
||||
* @param bool $swapRB
|
||||
* @param bool $crop
|
||||
* @return Mat
|
||||
*/
|
||||
function blobFromImage(Mat $image, float $scalefactor = 1.0, Size $size, Scalar $mean, $swapRB = true, $crop = true) {
|
||||
return new Mat();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @return Net
|
||||
*/
|
||||
function readNetFromTorch(string $filename) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $protoFilename
|
||||
* @param string $modelFilename
|
||||
* @return Net
|
||||
*/
|
||||
function readNetFromCaffe(string $protoFilename, $modelFilename) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $protoFilename
|
||||
* @param string $modelFilename
|
||||
* @return Net
|
||||
*/
|
||||
function readNetFromTensorflow(string $model, $config) {
|
||||
|
||||
}
|
||||
@@ -9,11 +9,11 @@ $src = cvtColor($src, CV\COLOR_BGR2RGB); // convert BGR to RGB
|
||||
\CV\copyMakeBorder($src, $src, 7, 7, 7, 7, 1); // add borders 7px
|
||||
//var_export($src);
|
||||
|
||||
$blob = \CV\DNN\Net::blobFromImage($src, 1, $src->size(), new Scalar()); // convert image to 4 dimensions matrix
|
||||
$blob = \CV\DNN\blobFromImage($src, 1, $src->size(), new Scalar()); // convert image to 4 dimensions matrix
|
||||
//var_export($blob);
|
||||
$blob = $blob->divide(255); // convert color values from 0-255 to 0-1
|
||||
|
||||
$net = \CV\DNN\Net::readNetFromCaffe('models/waifu2x/scale2.0x_model.prototxt', 'models/waifu2x/scale2.0x_model.caffemodel');
|
||||
$net = \CV\DNN\readNetFromCaffe('models/waifu2x/scale2.0x_model.prototxt', 'models/waifu2x/scale2.0x_model.caffemodel');
|
||||
|
||||
$net->setInput($blob, "");
|
||||
|
||||
@@ -26,9 +26,9 @@ $mat = new \CV\Mat($r->shape[2], $r->shape[3], CV\CV_32FC3);
|
||||
|
||||
for ($i = 0; $i < $r->shape[2]; $i++) {
|
||||
for ($j = 0; $j < $r->shape[3]; $j++) {
|
||||
$mat->at($i, $j, 0, $r->atIdx([0,0,$i,$j], 1)); //R
|
||||
$mat->at($i, $j, 1, $r->atIdx([0,1,$i,$j], 1)); //G
|
||||
$mat->at($i, $j, 2, $r->atIdx([0,2,$i,$j], 1)); //B
|
||||
$mat->at($i, $j, 0, $r->atIdx([0,0,$i,$j])); //R
|
||||
$mat->at($i, $j, 1, $r->atIdx([0,1,$i,$j])); //G
|
||||
$mat->at($i, $j, 2, $r->atIdx([0,2,$i,$j])); //B
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário