Skip to content

Commit caf9cad

Browse files
committed
Merge branch 'dev'
2 parents 97a50bf + da8376e commit caf9cad

21 files changed

+242
-99
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ install:
3737
- sudo apt-get install -y python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev -qq
3838

3939
# Download OpenCV-contrib v3.3.0-rc
40-
- git clone https://github.com/opencv/opencv_contrib.git
41-
- cd opencv_contrib
42-
- git checkout 3.3.0-rc
43-
- cd ..
40+
#- git clone https://github.com/opencv/opencv_contrib.git
41+
#- cd opencv_contrib
42+
#- git checkout 3.3.0-rc
43+
#- cd ..
4444

4545
# Download OpenCV v3.3.0-rc
4646
- git clone https://github.com/opencv/opencv.git
@@ -52,7 +52,8 @@ install:
5252
- cd build
5353

5454
# Set build instructions for Ubuntu distro.
55-
- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
55+
#- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
56+
- cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
5657
# Run 'make' with four threads.
5758
- make -j6
5859

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,25 +118,26 @@ result:
118118

119119

120120
## Features
121-
- 1.calib3d
122-
- 2.contrib
123-
- 3.core
124-
- 4.imgproc
125-
- 5.features2d
126-
- 6.flann
127-
- 7.gpu
128-
- 8.highgui
129-
- 9.legacy
130-
- 10.ml
131-
- 11.nonfree
132-
- 12.objdetect
133-
- 13.ocl
134-
- 14.photo
135-
- 15.stitching
136-
- 16.superres
137-
- 17.ts
138-
- 18.video
139-
- 19.Videostab
121+
- [x]1.[core](http://phpopencv.org/zh-cn/docs/mat.html)
122+
- [x]2.[imgproc](http://phpopencv.org/zh-cn/docs/gausian_median_blur_bilateral_filter.html)
123+
- [ ]3.highgui
124+
- [ ]4.contrib
125+
- [ ]5.features2d
126+
- [ ]6.flann
127+
- [ ]7.gpu
128+
- [ ]8.calib3d
129+
- [ ]9.legacy
130+
- [ ]10.ml
131+
- [ ]11.nonfree
132+
- [ ]12.objdetect
133+
- [ ]13.ocl
134+
- [ ]14.photo
135+
- [ ]15.stitching
136+
- [ ]16.superres
137+
- [ ]17.ts
138+
- [ ]18.video
139+
- [ ]19.Videostab
140+
140141

141142

142143
## Contributors

config.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if test "$PHP_OPENCV" != "no"; then
3434

3535
opencv_source_file="opencv.cc \
3636
source/opencv2/core/opencv_mat.cc \
37+
source/opencv2/core/opencv_utility.cc \
3738
source/opencv2/opencv_imgcodecs.cc \
3839
opencv_exception.cc \
3940
source/opencv2/core/hal/opencv_interface.cc \

opencv.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extern "C" {
4040
#include "source/opencv2/opencv_objdetect.h"
4141
#include "source/opencv2/opencv_videoio.h"
4242
#include "source/opencv2/opencv_face.h"
43+
#include "source/opencv2/core/opencv_utility.h"
4344

4445
/* If you declare any globals in php_opencv.h uncomment this:
4546
ZEND_DECLARE_MODULE_GLOBALS(opencv)
@@ -231,6 +232,8 @@ const zend_function_entry opencv_functions[] = {
231232
ZEND_NS_NAMED_FE(OPENCV_NS, threshold, ZEND_FN(opencv_threshold), opencv_threshold_arginfo)
232233
ZEND_NS_NAMED_FE(OPENCV_NS, morphologyEx, ZEND_FN(opencv_morphology_ex), opencv_morphology_ex_arginfo)
233234
ZEND_NS_NAMED_FE(OPENCV_NS, LUT, ZEND_FN(opencv_lut), opencv_lut_arginfo)
235+
ZEND_NS_NAMED_FE(OPENCV_NS, getTickCount, ZEND_FN(opencv_get_tick_count), NULL)
236+
ZEND_NS_NAMED_FE(OPENCV_NS, getTickFrequency, ZEND_FN(opencv_get_tick_frequency), NULL)
234237
PHP_FE_END /* Must be the last line in opencv_functions[] */
235238
};
236239
/* }}} */

opencv_exception.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
/* $Id$ */
1919

20-
#ifdef HAVE_CONFIG_H
21-
#include "config.h"
22-
#endif
2320

2421
#include "php_opencv.h"
2522
#include "zend_exceptions.h"

source/opencv2/core/hal/opencv_interface.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
#include "../../../../php_opencv.h"
1818
#include "opencv_interface.h"
1919

20-
#ifdef HAVE_CONFIG_H
21-
#include "config.h"
22-
#endif
23-
2420

2521
void opencv_interface_init(int module_number)
2622
{

source/opencv2/core/opencv_base.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
#include "../../../php_opencv.h"
1818
#include "opencv_base.h"
1919

20-
#ifdef HAVE_CONFIG_H
21-
#include "config.h"
22-
#endif
2320

2421

2522
void opencv_border_types_init(int module_number){

source/opencv2/core/opencv_mat.cc

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
#ifdef HAVE_CONFIG_H
18-
#include "config.h"
19-
#endif
2017

2118
#include "../../../php_opencv.h"
2219
#include "opencv_mat.h"
@@ -366,6 +363,7 @@ PHP_METHOD(opencv_mat, copy_to)
366363
}
367364

368365
/**
366+
* //todo int,fload,double
369367
* CV\Mat->at
370368
* @param execute_data
371369
* @param return_value
@@ -386,10 +384,10 @@ PHP_METHOD(opencv_mat, at)
386384
this_object->mat->at<uchar>((int)row,(int)col);
387385
break;
388386
case 2:
389-
RETURN_LONG(this_object->mat->at<Vec2b>((int)row,(int)col)[channel]);
387+
RETURN_LONG(this_object->mat->at<Vec2b>((int)row,(int)col)[channel]);
390388
break;
391389
case 3:
392-
RETURN_LONG(this_object->mat->at<Vec3b>((int)row,(int)col)[channel]);
390+
RETURN_LONG(this_object->mat->at<Vec3b>((int)row,(int)col)[channel]);
393391
break;
394392
case 4:
395393
RETURN_LONG(this_object->mat->at<Vec4b>((int)row,(int)col)[channel]);
@@ -399,27 +397,52 @@ PHP_METHOD(opencv_mat, at)
399397
break;
400398
}
401399

400+
402401
}else{
403402
//set px value
404403
convert_to_long(value_zval);
405404
zend_long value = Z_LVAL_P(value_zval);
406-
switch (this_object->mat->channels()){
407-
case 1:
408-
this_object->mat->at<uchar>((int)row,(int)col) = saturate_cast<uchar>(value);
409-
break;
410-
case 2:
411-
this_object->mat->at<Vec2b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
412-
break;
413-
case 3:
414-
this_object->mat->at<Vec3b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
415-
break;
416-
case 4:
417-
this_object->mat->at<Vec4b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
405+
switch(this_object->mat->depth()){
406+
case CV_8U:
407+
switch (this_object->mat->channels()){
408+
case 1:
409+
this_object->mat->at<uchar>((int)row,(int)col) = saturate_cast<uchar>(value);
410+
break;
411+
case 2:
412+
this_object->mat->at<Vec2b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
413+
break;
414+
case 3:
415+
this_object->mat->at<Vec3b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
416+
break;
417+
case 4:
418+
this_object->mat->at<Vec4b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
419+
break;
420+
default:
421+
opencv_throw_exception("Get Mat px only channel in 1,2,3,4.");
422+
break;
423+
}
418424
break;
419425
default:
420-
opencv_throw_exception("Get Mat px only channel in 1,2,3,4.");
426+
switch (this_object->mat->channels()){
427+
case 1:
428+
this_object->mat->at<uchar>((int)row,(int)col) = saturate_cast<char>(value);
429+
break;
430+
case 2:
431+
this_object->mat->at<Vec2b>((int)row,(int)col)[channel]=saturate_cast<char>(value);
432+
break;
433+
case 3:
434+
this_object->mat->at<Vec3b>((int)row,(int)col)[channel]=saturate_cast<char>(value);
435+
break;
436+
case 4:
437+
this_object->mat->at<Vec4b>((int)row,(int)col)[channel]=saturate_cast<char>(value);
438+
break;
439+
default:
440+
opencv_throw_exception("Get Mat px only channel in 1,2,3,4.");
441+
break;
442+
}
421443
break;
422444
}
445+
423446
}
424447
RETURN_NULL();
425448
}
@@ -531,6 +554,30 @@ PHP_METHOD(opencv_mat, divide)
531554
RETURN_ZVAL(&instance,0,0); //return php Mat object
532555
}
533556

557+
558+
559+
/**
560+
* //todo mask
561+
* Mat->setTo(Scalar $value)
562+
* @param execute_data
563+
* @param return_value
564+
*/
565+
PHP_METHOD(opencv_mat, set_to)
566+
{
567+
zval *value_zval;
568+
569+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &value_zval, opencv_scalar_ce) == FAILURE) {
570+
RETURN_NULL();
571+
}
572+
573+
opencv_mat_object *this_obj = Z_PHP_MAT_OBJ_P(getThis());
574+
opencv_scalar_object *value_obj = Z_PHP_SCALAR_OBJ_P(value_zval);
575+
this_obj->mat->setTo(*value_obj->scalar);
576+
577+
RETURN_NULL();
578+
579+
}
580+
534581
/**
535582
* opencv_mat_methods[]
536583
*/
@@ -556,6 +603,7 @@ const zend_function_entry opencv_mat_methods[] = {
556603
PHP_MALIAS(opencv_mat, convertTo ,convert_to, opencv_mat_convert_to_arginfo, ZEND_ACC_PUBLIC)
557604
PHP_ME(opencv_mat, plus, NULL, ZEND_ACC_PUBLIC)
558605
PHP_ME(opencv_mat, divide, NULL, ZEND_ACC_PUBLIC)
606+
PHP_MALIAS(opencv_mat, setTo ,set_to, NULL, ZEND_ACC_PUBLIC)
559607
PHP_FE_END
560608
};
561609
/* }}} */

source/opencv2/core/opencv_type.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17-
#ifdef HAVE_CONFIG_H
18-
#include "config.h"
19-
#endif
2017

2118
#include "../../../php_opencv.h"
2219
#include "opencv_type.h"

source/opencv2/core/opencv_utility.cc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP-OpenCV |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 2.0 of the Apache license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| http://www.apache.org/licenses/LICENSE-2.0.html |
9+
| If you did not receive a copy of the Apache2.0 license and are unable|
10+
| to obtain it through the world-wide-web, please send a note to |
11+
| hihozhou@gmail.com so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
| Author: HaiHao Zhou <hihozhou@gmail.com> |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
18+
19+
#include "../../../php_opencv.h"
20+
#include "opencv_utility.h"
21+
22+
void opencv_utility_init(int module_number){
23+
24+
}
25+
26+
/**
27+
* CV\getTickCount
28+
* @param execute_data
29+
* @param return_value
30+
*/
31+
PHP_FUNCTION(opencv_get_tick_count){
32+
long tick_count = getTickCount();
33+
RETURN_LONG(tick_count);
34+
}
35+
36+
37+
/**
38+
* getTickFrequency
39+
* @param execute_data
40+
* @param return_value
41+
*/
42+
PHP_FUNCTION(opencv_get_tick_frequency){
43+
double tick_frequency = getTickFrequency();
44+
RETURN_DOUBLE(tick_frequency);
45+
}

source/opencv2/core/opencv_utility.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP-OpenCV |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 2.0 of the Apache license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| http://www.apache.org/licenses/LICENSE-2.0.html |
9+
| If you did not receive a copy of the Apache2.0 license and are unable|
10+
| to obtain it through the world-wide-web, please send a note to |
11+
| hihozhou@gmail.com so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
| Author: HaiHao Zhou <hihozhou@gmail.com> |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#ifndef PHP_OPENCV_UTILITY_H
18+
#define PHP_OPENCV_UTILITY_H
19+
20+
#endif //PHP_OPENCV_UTILITY_H
21+
22+
void opencv_utility_init(int module_number);
23+
24+
PHP_FUNCTION(opencv_get_tick_count);
25+
PHP_FUNCTION(opencv_get_tick_frequency);

0 commit comments

Comments
 (0)