@@ -169,16 +169,15 @@ PHP_FUNCTION(opencv_create_trackbar){
169169
170170 zend_fcall_info fci;
171171 zend_fcall_info_cache fci_cache;
172- zend_bool is_null;
173172 if (zend_parse_parameters (ZEND_NUM_ARGS (), " ssll|f!" ,
174173 &trackbarname, &trackbarname_len,
175174 &winname,&winname_len,
176175 &value,&count,
177- &fci, &fci_cache,&is_null ) == FAILURE) {
176+ &fci, &fci_cache) == FAILURE) {
178177 return ;
179178 }
180179 opencv_fcall_info_cb *cb = 0 ;
181- if (fci.size > 0 && ZEND_NUM_ARGS () > 4 ) {
180+ if (fci.size > 0 && ZEND_NUM_ARGS () > 4 ) {// check callback param is valid
182181 cb = opencv_fcall_info_cb_create (&fci, &fci_cache);
183182 }
184183 int *trackbar_value_ptr = new int (value);
@@ -214,6 +213,53 @@ PHP_FUNCTION(opencv_get_track_bar_pos){
214213}
215214
216215
216+ void opencv_on_mouse_callback (int event, int x, int y, int flags, void * userdata){
217+ if (userdata != 0 ){
218+ opencv_fcall_info_cb *fci_s=(opencv_fcall_info_cb*)userdata;
219+ zval retval;
220+ zval args[4 ];
221+ ZVAL_LONG (&args[0 ], (long )event);
222+ ZVAL_LONG (&args[1 ], (long )x);
223+ ZVAL_LONG (&args[2 ], (long )y);
224+ ZVAL_LONG (&args[3 ], (long )flags);
225+ fci_s->fci ->param_count = 4 ;
226+ fci_s->fci ->params = args;
227+ fci_s->fci ->retval = &retval;
228+
229+ zend_call_function (fci_s->fci , fci_s->fci_cache );
230+ zval_ptr_dtor (&args[0 ]);
231+ zval_ptr_dtor (&args[1 ]);
232+ zval_ptr_dtor (&args[2 ]);
233+ zval_ptr_dtor (&args[3 ]);
234+ }
235+ }
236+
237+ /* *
238+ * CV\setMouseCallback
239+ * @param execute_data
240+ * @param return_value
241+ */
242+ PHP_FUNCTION (opencv_set_mouse_callback){
243+ char *winname;
244+ long winname_len;
245+
246+ zend_fcall_info fci;
247+ zend_fcall_info_cache fci_cache;
248+ if (zend_parse_parameters (ZEND_NUM_ARGS (), " s|f!" ,
249+ &winname,&winname_len,
250+ &fci, &fci_cache) == FAILURE) {
251+ return ;
252+ }
253+ opencv_fcall_info_cb *cb = 0 ;
254+ if (fci.size > 0 && ZEND_NUM_ARGS () > 1 ) {// check callback param is valid
255+ cb = opencv_fcall_info_cb_create (&fci, &fci_cache);
256+ }
257+ setMouseCallback (winname, opencv_on_mouse_callback, cb);
258+ RETURN_NULL ();
259+ }
260+
261+
262+
217263void opencv_highgui_init (int module_number)
218264{
219265 /* *
0 commit comments