Skip to content

Commit

Permalink
delete include config.h and check HAVE_OPENCV_FACE
Browse files Browse the repository at this point in the history
  • Loading branch information
hihozhou committed Sep 20, 2017
1 parent 9b09e31 commit 98ff72b
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 68 deletions.
39 changes: 20 additions & 19 deletions README.md
Expand Up @@ -118,25 +118,26 @@ result:


## Features
- 1.calib3d
- 2.contrib
- 3.core
- 4.imgproc
- 5.features2d
- 6.flann
- 7.gpu
- 8.highgui
- 9.legacy
- 10.ml
- 11.nonfree
- 12.objdetect
- 13.ocl
- 14.photo
- 15.stitching
- 16.superres
- 17.ts
- 18.video
- 19.Videostab
- [x]1.[core](http://phpopencv.org/zh-cn/docs/mat.html)
- [x]2.[imgproc](http://phpopencv.org/zh-cn/docs/gausian_median_blur_bilateral_filter.html)
- [ ]3.highgui
- [ ]4.contrib
- [ ]5.features2d
- [ ]6.flann
- [ ]7.gpu
- [ ]8.calib3d
- [ ]9.legacy
- [ ]10.ml
- [ ]11.nonfree
- [ ]12.objdetect
- [ ]13.ocl
- [ ]14.photo
- [ ]15.stitching
- [ ]16.superres
- [ ]17.ts
- [ ]18.video
- [ ]19.Videostab



## Contributors
Expand Down
3 changes: 0 additions & 3 deletions opencv_exception.cc
Expand Up @@ -17,9 +17,6 @@

/* $Id$ */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php_opencv.h"
#include "zend_exceptions.h"
Expand Down
4 changes: 0 additions & 4 deletions source/opencv2/core/hal/opencv_interface.cc
Expand Up @@ -17,10 +17,6 @@
#include "../../../../php_opencv.h"
#include "opencv_interface.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


void opencv_interface_init(int module_number)
{
Expand Down
3 changes: 0 additions & 3 deletions source/opencv2/core/opencv_base.cc
Expand Up @@ -17,9 +17,6 @@
#include "../../../php_opencv.h"
#include "opencv_base.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif


void opencv_border_types_init(int module_number){
Expand Down
59 changes: 41 additions & 18 deletions source/opencv2/core/opencv_mat.cc
Expand Up @@ -14,9 +14,6 @@
+----------------------------------------------------------------------+
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "../../../php_opencv.h"
#include "opencv_mat.h"
Expand Down Expand Up @@ -366,6 +363,7 @@ PHP_METHOD(opencv_mat, copy_to)
}

/**
* //todo int,fload,double
* CV\Mat->at
* @param execute_data
* @param return_value
Expand All @@ -386,10 +384,10 @@ PHP_METHOD(opencv_mat, at)
this_object->mat->at<uchar>((int)row,(int)col);
break;
case 2:
RETURN_LONG(this_object->mat->at<Vec2b>((int)row,(int)col)[channel]);
RETURN_LONG(this_object->mat->at<Vec2b>((int)row,(int)col)[channel]);
break;
case 3:
RETURN_LONG(this_object->mat->at<Vec3b>((int)row,(int)col)[channel]);
RETURN_LONG(this_object->mat->at<Vec3b>((int)row,(int)col)[channel]);
break;
case 4:
RETURN_LONG(this_object->mat->at<Vec4b>((int)row,(int)col)[channel]);
Expand All @@ -399,27 +397,52 @@ PHP_METHOD(opencv_mat, at)
break;
}


}else{
//set px value
convert_to_long(value_zval);
zend_long value = Z_LVAL_P(value_zval);
switch (this_object->mat->channels()){
case 1:
this_object->mat->at<uchar>((int)row,(int)col) = saturate_cast<uchar>(value);
break;
case 2:
this_object->mat->at<Vec2b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
break;
case 3:
this_object->mat->at<Vec3b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
break;
case 4:
this_object->mat->at<Vec4b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
switch(this_object->mat->depth()){
case CV_8U:
switch (this_object->mat->channels()){
case 1:
this_object->mat->at<uchar>((int)row,(int)col) = saturate_cast<uchar>(value);
break;
case 2:
this_object->mat->at<Vec2b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
break;
case 3:
this_object->mat->at<Vec3b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
break;
case 4:
this_object->mat->at<Vec4b>((int)row,(int)col)[channel]=saturate_cast<uchar>(value);
break;
default:
opencv_throw_exception("Get Mat px only channel in 1,2,3,4.");
break;
}
break;
default:
opencv_throw_exception("Get Mat px only channel in 1,2,3,4.");
switch (this_object->mat->channels()){
case 1:
this_object->mat->at<uchar>((int)row,(int)col) = saturate_cast<char>(value);
break;
case 2:
this_object->mat->at<Vec2b>((int)row,(int)col)[channel]=saturate_cast<char>(value);
break;
case 3:
this_object->mat->at<Vec3b>((int)row,(int)col)[channel]=saturate_cast<char>(value);
break;
case 4:
this_object->mat->at<Vec4b>((int)row,(int)col)[channel]=saturate_cast<char>(value);
break;
default:
opencv_throw_exception("Get Mat px only channel in 1,2,3,4.");
break;
}
break;
}

}
RETURN_NULL();
}
Expand Down
3 changes: 0 additions & 3 deletions source/opencv2/core/opencv_type.cc
Expand Up @@ -14,9 +14,6 @@
+----------------------------------------------------------------------+
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "../../../php_opencv.h"
#include "opencv_type.h"
Expand Down
3 changes: 0 additions & 3 deletions source/opencv2/core/opencv_utility.cc
Expand Up @@ -15,9 +15,6 @@
*/


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "../../../php_opencv.h"
#include "opencv_utility.h"
Expand Down
1 change: 1 addition & 0 deletions source/opencv2/face/opencv_facerec.cc
Expand Up @@ -15,6 +15,7 @@
*/



#include "opencv_facerec.h"
#include "../opencv_face.h"
#include "../core/opencv_mat.h"
Expand Down
3 changes: 0 additions & 3 deletions source/opencv2/imgcodecs/opencv_imgcodecs_c.cc
Expand Up @@ -16,7 +16,4 @@

#include "../../../php_opencv.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

3 changes: 0 additions & 3 deletions source/opencv2/opencv_core.cc
Expand Up @@ -21,9 +21,6 @@
#include "../../opencv_exception.h"
#include "core/opencv_type.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

zend_class_entry *opencv_formatter_ce;

Expand Down
17 changes: 15 additions & 2 deletions source/opencv2/opencv_face.cc
Expand Up @@ -15,10 +15,14 @@
*/

#include "opencv_face.h"
#include "face/opencv_facerec.h"

zend_class_entry *opencv_face_recognizer_ce;

#ifdef HAVE_OPENCV_FACE

#include "face/opencv_facerec.h"


/**
* opencv_face_recognizer_methods[]
*/
Expand All @@ -38,4 +42,13 @@ void opencv_face_init(int module_number){
opencv_face_recognizer_init(module_number);
opencv_lbph_face_recognizer_init(module_number);
opencv_base_face_recognizer_init(module_number);
}
}

#else

void opencv_face_init(int module_number){

}

#endif

9 changes: 2 additions & 7 deletions source/opencv2/opencv_highgui.cc
Expand Up @@ -21,9 +21,6 @@
#include "../../opencv_exception.h"


#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

/**
* //todo only cli can call this function
Expand Down Expand Up @@ -134,7 +131,7 @@ opencv_fcall_info_cb * opencv_fcall_info_cb_create(zend_fcall_info *fci_ptr, zen

memcpy(cb->fci, fci_ptr, sizeof(zend_fcall_info));
memcpy(cb->fci_cache, fci_cache_ptr, sizeof(zend_fcall_info_cache));
Z_TRY_ADDREF(cb->fci->function_name);
Z_TRY_ADDREF(cb->fci->function_name);//todo 滑动调或窗口销毁是释放内存
cb->fci->param_count = 0;
cb->fci->no_separation = 1;
cb->fci->retval = NULL;
Expand Down Expand Up @@ -178,9 +175,7 @@ PHP_FUNCTION(opencv_create_trackbar){
&fci, &fci_cache) == FAILURE) {
return;
}

int *trackbar_value_ptr = new int(value);

opencv_fcall_info_cb *cb = opencv_fcall_info_cb_create(&fci, &fci_cache);
createTrackbar(trackbarname, winname, trackbar_value_ptr, (int)count,opencv_create_trackbar_callback,cb);
RETURN_NULL();
Expand All @@ -207,7 +202,7 @@ PHP_FUNCTION(opencv_get_track_bar_pos){
char *trackbarname, *winname;
long trackbarname_len, winname_len;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &trackbarname, &trackbarname_len, &winname, &winname_len) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &trackbarname, &trackbarname_len, &winname, &winname_len) == FAILURE) {
return;
}
RETURN_LONG(getTrackbarPos(trackbarname, winname))
Expand Down
7 changes: 7 additions & 0 deletions source/opencv2/opencv_highgui.h
Expand Up @@ -24,6 +24,13 @@ PHP_FUNCTION(opencv_imshow);
PHP_FUNCTION(opencv_wait_key);
PHP_FUNCTION(opencv_move_window);
PHP_FUNCTION(opencv_named_window);
ZEND_BEGIN_ARG_INFO_EX(opencv_create_trackbar_arginfo, 0, 0, 5)
ZEND_ARG_INFO(0, trackbarname)
ZEND_ARG_INFO(0, winname)
ZEND_ARG_INFO(1, value)
ZEND_ARG_INFO(0, count)
ZEND_ARG_INFO(0, onChange)
ZEND_END_ARG_INFO()
PHP_FUNCTION(opencv_create_trackbar);
PHP_FUNCTION(opencv_destroy_window);
PHP_FUNCTION(opencv_get_track_bar_pos);
Expand Down
7 changes: 7 additions & 0 deletions source/opencv2/opencv_imgproc.cc
Expand Up @@ -26,6 +26,7 @@ void opencv_imgproc_init(int module_number)
{
opencv_color_conversion_code_init(module_number);
opencv_line_type_init(module_number);
opencv_morph_shapes(module_number);
}

/**
Expand Down Expand Up @@ -1247,3 +1248,9 @@ void opencv_line_type_init(int module_number){
REGISTER_NS_LONG_CONSTANT(OPENCV_NS, "LINE_8", LINE_8, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT(OPENCV_NS, "LINE_AA", LINE_AA, CONST_CS | CONST_PERSISTENT);
}

void opencv_morph_shapes(int module_number){
REGISTER_NS_LONG_CONSTANT(OPENCV_NS, "MORPH_RECT", MORPH_RECT, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT(OPENCV_NS, "MORPH_CROSS", MORPH_CROSS, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT(OPENCV_NS, "MORPH_ELLIPSE", MORPH_ELLIPSE, CONST_CS | CONST_PERSISTENT);
}
1 change: 1 addition & 0 deletions source/opencv2/opencv_imgproc.h
Expand Up @@ -20,6 +20,7 @@
void opencv_imgproc_init(int module_number);
void opencv_color_conversion_code_init(int module_number);
void opencv_line_type_init(int module_number);
void opencv_morph_shapes(int module_number);
PHP_FUNCTION(opencv_cv_t_color);
PHP_FUNCTION(opencv_ellipse);
PHP_FUNCTION(opencv_circle);
Expand Down

0 comments on commit 98ff72b

Please sign in to comment.