You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First let me thank you for PHPCPP which is very cool and way nicer than doing PHP extensions in C !
However, I have stumbled on a problem I have no idea how to solve !
I am trying to translate this PHP function to CPP:
privatefunctionmerge_and_clear() {
$det_regions = array();
$this->skin_regions = array();
foreach ($this->merge_regionsas$i => $mr) {
if (!isset($det_regions[$i])) {
$det_regions[$i] = array();
}
foreach ($mras$m) {
if (!empty($this->detected_regions[$m])) {
$det_regions[$i] = array_merge($det_regions[$i], $this->detected_regions[$m]);
}
unset($this->detected_regions[$m]);
}
}
if (!empty($this->detected_regions)) {
foreach ($this->detected_regionsas$dr) {
$det_regions[] = $dr;
}
}
// only pushes regions which are bigger than a specific amount to the final resultforeach ($det_regionsas$dt) {
$count_dt = count($dt);
if ($count_dt > 30) {
$this->skin_regions[] = $count_dt;
}
}
}
All arrays are multi-dimensional in the PHP code above.
My translation:
/** * Get merge_regions pixel data, get only regions of certain size and store to skin_regions * data in skin_regions will be used to determine if picture contains nudity or not*/private:voidmerge_and_clear() {
Php::Value _s_det_regions = Php::Array();
this->_s_skin_regions = this->_s_skin_regions(); // Empty the _s_skin_regions array//foreach ($this->merge_regions as $i => $mr) {//while(list(_s_i, _s_mr) = each(this->_s_merge_regions)) {for (auto &iter : this->_s_merge_regions) {
int _s_i = (int) iter.first;
Php::Value _s_mr = iter.second;
if (! Php::isset(_s_det_regions[_s_i])) {
Php::Value empty = Php::Array();
_s_det_regions[_s_i] = empty;
}
//foreach ($mr as $m) {//for(size_t _s_kk=0; _s_kk < Php::count(_s_mr); _s_kk++) {for (auto &iter2 : _s_mr) {
int _s_m = (int) iter2.second;
if (!Php::empty(this->_s_detected_regions[_s_m])) {
//_s_det_regions[_s_i] = array_merge(_s_det_regions[_s_i], this->_s_detected_regions[_s_m]);
Php::Value temp = Php::call("array_merge", _s_det_regions[_s_i], this->_s_detected_regions[_s_m]); // THIS IS THE OFFENDING LINE
Php::Array temparr = temp;
_s_det_regions[_s_i] = temparr;
// FIXME//_s_det_regions[_s_i] = Php::call("array_merge", _s_det_regions[_s_i], this->_s_detected_regions[_s_m]);// FIXME END
}
Php::unset(this->_s_detected_regions[_s_m]);
}
} // forif (Php::count(this->_s_detected_regions) > 0) {
//foreach ($this->detected_regions as $dr) {//for(size_t _s_kkk=0; _s_kkk < Php::count(this->_s_detected_regions); _s_kkk++) {for (auto &iter3 : this->_s_detected_regions) {
int _s_dr = (int) iter3.second;
//Php::Value _s_dr = this->_s_detected_regions[_s_kkk];//_s_det_regions[_APPEND_] = _s_dr;Php::array_push(_s_det_regions, _s_dr);
}
}
// only pushes regions which are bigger than a specific amount to the final result//foreach ($det_regions as $dt) {//for (auto &iter4 : _s_det_regions) {int _s_det_regions_count = Php::count(_s_det_regions);
for(size_t _s_k=0; _s_k < _s_det_regions_count; _s_k++) {
Php::Value _s_dt = _s_det_regions[_s_k];
//Php::Array _s_dt = iter4.second;int _s_count_dt = Php::count(_s_dt);
if (_s_count_dt > 30) {
//this->_s_skin_regions[_APPEND_] = _s_count_dt;Php::array_push(this->_s_skin_regions, _s_count_dt);
}
}
}
The error I am getting is
Main.cpp: In member function ‘void NudityFilter::merge_and_clear()’:
Main.cpp:565:80: error: call of overloaded ‘Value(Php::HashMember)’ is ambiguous
Php::Value temp = Php::call("array_merge", _s_det_regions[_s_i], this->_s_detected_regions[_s_m]);
For information, the properties of the CPP class are declared as:
private:
std::string _s_file; // full path of image file
std::string _s_filename; // image file nameint _s_img_w; // image widthint _s_img_h; // image heightint _s_last_from; // previous `from` region numberint _s_last_to; // previous `to` region number
Php::Value _s_pixel_map; // array of skin pixel holding region number
Php::Value _s_merge_regions; // array of pixel number which are merged in a region
Php::Value _s_detected_regions; // array of skin pixel for arranging region number
Php::Value _s_skin_regions; // array of skin regions, store number of pixels in a regionpublic:
Php::Array _s_log; // array of log message
How can I fix this ?
Please help !
The text was updated successfully, but these errors were encountered:
First let me thank you for PHPCPP which is very cool and way nicer than doing PHP extensions in C !
However, I have stumbled on a problem I have no idea how to solve !
I am trying to translate this PHP function to CPP:
All arrays are multi-dimensional in the PHP code above.
My translation:
The error I am getting is
Main.cpp: In member function ‘void NudityFilter::merge_and_clear()’:
Main.cpp:565:80: error: call of overloaded ‘Value(Php::HashMember)’ is ambiguous
Php::Value temp = Php::call("array_merge", _s_det_regions[_s_i], this->_s_detected_regions[_s_m]);
For information, the properties of the CPP class are declared as:
How can I fix this ?
Please help !
The text was updated successfully, but these errors were encountered: