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

Help installing the extension on Windows

BbenWeb1 opened this issue · comments

Welcome ,
Can you explain the installation steps on Windows more clearly?

opencv.cc
opencv_exception.cc
opencv_interface.cc
opencv_base.cc
opencv_cvdef.cc
opencv_mat.cc
opencv_persistence.cc
opencv_type.cc
ext\php_opencv\source/opencv2/core/opencv_mat.cc(197): error C2131: expression did not evaluate to a constant
ext\php_opencv\source/opencv2/core/opencv_mat.cc(197): note: failure was caused by a read of a variable outside its lifetime
ext\php_opencv\source/opencv2/core/opencv_mat.cc(197): note: see usage of 'dims'
ext\php_opencv\source/opencv2/core/opencv_mat.cc(210): error C3863: array type 'int [dims]' is not assignable
ext\php_opencv\source/opencv2/core/opencv_mat.cc(220): error C2668: 'cv::Mat::Mat': ambiguous call to overloaded function
D:\opencv\build\include\opencv2/core/mat.hpp(865): note: could be 'cv::Mat::Mat(int,const int *,int)' (compiling source file ext\php_opencv\source/opencv2/core/opencv_mat.cc)
D:\opencv\build\include\opencv2/core/mat.hpp(827): note: or 'cv::Mat::Mat(int,int,int)' (compiling source file ext\php_opencv\source/opencv2/core/opencv_mat.cc)
ext\php_opencv\source/opencv2/core/opencv_mat.cc(220): note: while trying to match the argument list '(int, int [dims], int)'
opencv_utility.cc
opencv_dnn.cc
opencv_facemarkLBF.cc
opencv_facerec.cc
opencv_imgcodecs_c.cc
opencv_core.cc
opencv_face.cc
opencv_highgui.cc
opencv_imgcodecs.cc
opencv_imgproc.cc
opencv_ml.cc
opencv_objdetect.cc
opencv_videoio.cc
ext\php_opencv\source/opencv2/opencv_imgproc.cc(151): error C2131: expression did not evaluate to a constant
ext\php_opencv\source/opencv2/opencv_imgproc.cc(151): note: failure was caused by a read of a variable outside its lifetime
ext\php_opencv\source/opencv2/opencv_imgproc.cc(151): note: see usage of 'ncontours'
ext\php_opencv\source/opencv2/opencv_imgproc.cc(151): error C2131: expression did not evaluate to a constant
ext\php_opencv\source/opencv2/opencv_imgproc.cc(151): note: failure was caused by a read of a variable outside its lifetime
ext\php_opencv\source/opencv2/opencv_imgproc.cc(151): note: see usage of 'point_count'
ext\php_opencv\source/opencv2/opencv_imgproc.cc(159): error C3863: array type 'cv::Point [ncontours][point_count]' is not assignable
ext\php_opencv\source/opencv2/opencv_imgproc.cc(169): error C2131: expression did not evaluate to a constant
ext\php_opencv\source/opencv2/opencv_imgproc.cc(169): note: failure was caused by a read of a variable outside its lifetime
ext\php_opencv\source/opencv2/opencv_imgproc.cc(169): note: see usage of 'ncontours'
ext\php_opencv\source/opencv2/opencv_imgproc.cc(170): error C3863: array type 'const cv::Point *[ncontours]' is not assignable

    "cl.exe" /D COMPILE_DL_OPENCV /D OPENCV_EXPORTS=1 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /nologo /I . /I main /I Zend /I TSRM /I ext /D _WINDOWS /D WINDOWS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D _MBCS /D _USE_MATH_DEFINES /EHsc /I /K /DEBUG /FD /wd4996 /Qspectre /guard:cf /Zc:inline /Zc:__cplusplus /d2FuncCache1 /Zc:wchar_t /MP /LD /MD /Ox /D NDebug /D NDEBUG /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0 /D ZTS=1 /I "C:\pE\PE\php-sdk\php-8.0.20\vs16\x64\deps\include" /I "D:\opencv\build\include" /D FD_SETSIZE=256 /DHAVE_ARGON2ID_HASH_RAW=1 /FoC:\pE\PE\php-sdk\php-8.0.20\vs16\x64\php-src\x64\Release_TS\ext\php_opencv\ /FpC:\pE\PE\php-sdk\php-8.0.20\vs16\x64\php-src\x64\Release_TS\ext\php_opencv\ /FRC:\pE\PE\php-sdk\php-8.0.20\vs16\x64\php-src\x64\Release_TS\ext\php_opencv\ /FdC:\pE\PE\php-sdk\php-8.0.20\vs16\x64\php-src\x64\Release_TS\ext\php_opencv\ /c ext\php_opencv\opencv.cc ext\php_opencv\opencv_exception.cc ext\php_opencv\source/opencv2/core/hal/opencv_interface.cc ext\php_opencv\source/opencv2/core/opencv_base.cc ext\php_opencv\source/opencv2/core/opencv_cvdef.cc ext\php_opencv\source/opencv2/core/opencv_mat.cc ext\php_opencv\source/opencv2/core/opencv_persistence.cc ext\php_opencv\source/opencv2/core/opencv_type.cc ext\php_opencv\source/opencv2/core/opencv_utility.cc ext\php_opencv\source/opencv2/dnn/opencv_dnn.cc ext\php_opencv\source/opencv2/face/opencv_facemarkLBF.cc ext\php_opencv\source/opencv2/face/opencv_facerec.cc ext\php_opencv\source/opencv2/imgcodecs/opencv_imgcodecs_c.cc ext\php_opencv\source/opencv2/opencv_core.cc ext\php_opencv\source/opencv2/opencv_face.cc ext\php_opencv\source/opencv2/opencv_highgui.cc ext\php_opencv\source/opencv2/opencv_imgcodecs.cc ext\php_opencv\source/opencv2/opencv_imgproc.cc ext\php_opencv\source/opencv2/opencv_ml.cc ext\php_opencv\source/opencv2/opencv_objdetect.cc ext\php_opencv\source/opencv2/opencv_videoio.cc

opencv.cc
opencv_exception.cc
opencv_interface.cc
opencv_base.cc
opencv_cvdef.cc
opencv_mat.cc
opencv_persistence.cc
opencv_type.cc
opencv_utility.cc
opencv_dnn.cc
opencv_facemarkLBF.cc
opencv_facerec.cc
opencv_imgcodecs_c.cc
opencv_core.cc
opencv_face.cc
opencv_highgui.cc
opencv_imgcodecs.cc
opencv_imgproc.cc
opencv_ml.cc
opencv_objdetect.cc
opencv_videoio.cc

In the end, this code is repeated only

https://github.com/php-opencv/php-opencv/wiki/Installation.-php-opencv-windows

You must follow exactly the steps in the installation manual above.

I'm not a c/c++ programmer, but I need to do some settings to be able to compile, I made a pull request, but @morozovsk said he couldn't compile to approve, but he added step by step to compile to help anyone who wants

Observation:

If you can't compile the original version, try to clone the version in my repository on brach windows

https://github.com/wpj16/php-opencv/tree/windows

In it there are some small corrections of c/c++ errors that I solved by searching the internet and help from some friends

@morozovsk I suggest creating a branch tests for windows, and in it leave my version with the corrections I made https://github.com/wpj16/php-opencv/tree/windows, and add a code review request, so that in the future , when someone who masters c/c++ can compile, review and authorize merge with the master branch, Or even those who venture to install on windows can try this version.

Thanks for the reply. I tried to compile using the existing instructions. And by compiling the suffix itself by downloading php-dev. and use phpize.bat. But the same problem as it gets to create a dll file stops. I have used. branch windows of your project for C++ debugging

You can review this vedio https://youtu.be/wVnfw5exxGI

https://github.com/php-opencv/php-opencv/blob/master/source/opencv2/core/opencv_mat.cc

https://github.com/wpj16/php-opencv/blob/master/source/opencv2/core/opencv_mat.cc

analyzing your first error, and looking at the source of the files listed above, we can see that the error occurs because you have the wrong php-opencv version, it is possible to see a change between the two files, because in the project with my changes, the original code version is commented out


image


image

I added fix for this string in master branch for php 8.2.
It still works on linux and could be work on windows.
If it works on windows I can back port it in php 8.1/8.0/... etc.

All the changes I made were small like this, and I left the old code for more experienced people to review, and yes I compiled for all php versions above 8 and they worked.

It was working on windows but not on linux.
It could be compiled but tests for mat didn't work becase "Segmentation fault (core dumped)".

#40 (comment)

Thanks.

But what is the reason for this recurrence?
Untitled

Estava funcionando sem windows, mas não no linux. Poderia ser compilado, mas os testes para mat não funcionaram porque "Falha de segmentação (core dump)".

#40 (comentário)

Well unfortunately I didn't try to compile in linux, and I don't even know how to work very well with the compilation environment, I hope that someone who is a c++ programmer will help a solver, because it seems to be able to without just a small error.

But it's a great library, and I hope it has many updates.

Obrigado.

Mas qual é a razão dessa recorrência? Sem título

I think it must be a second compilation attempt, or redundancy in the library or sdk, but you can ignore it, and if the compilation works, let us know so that this item can be closed

Welcome .
During the past few days, I searched and studied the topic and was able to solve the problem, but I made changes in the file Config.w32 but it is not complete. I need to know for each files .cc the corresponding .lib files to complete it completely.
all this for installing automatic .

welcome.
You can review these corrections here : https://github.com/BbenWeb1/php-opencv/