php-opencv / php-opencv

opencv 4.5+ with dnn module for php 7/8

Home Page:https://github.com/php-opencv/php-opencv-examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call to undefined function CV\findContours()

michabbb opened this issue · comments

hi,

i am using php 8.2.8 via docker:

RUN wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip
RUN unzip opencv.zip
RUN mkdir -p build && cd build && cmake ../opencv-4.x && cmake --build . && make install

RUN apt-get install -y libopencv-dev
RUN git clone https://github.com/php-opencv/php-opencv.git
RUN cd php-opencv && phpize && ./configure --with-php-config=/usr/local/bin/php-config && make && make install && make test
RUN echo "extension=opencv.so" > /usr/local/etc/php/conf.d/docker-php-ext-opencv.ini

and here´s my code:

<?php

use function CV\{imread, cvtColor, GaussianBlur, threshold, findContours, drawContours, minAreaRect};
use const CV\{COLOR_BGR2GRAY, THRESH_BINARY, THRESH_OTSU, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE};
use CV\Size;
// ..................
list($contours, $_) = findContours($thresh, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);

I don´t understand why findContours is not available.
is my opencv version too old or did I miss something while compiling it ???

thanks for any help!!

hi.
Yes, this function does not exist by this name, but by another name

Another name is findContoursWithoutHierarchy