readNetFromDarknet, readNetFromONNX, readNetFromModelOptimizer
Esse commit está contido em:
@@ -254,6 +254,9 @@ const zend_function_entry opencv_functions[] = {
|
||||
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromCaffe, ZEND_FN(opencv_dnn_read_net_from_caffe), arginfo_void)
|
||||
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromTorch, ZEND_FN(opencv_dnn_read_net_from_torch), arginfo_void)
|
||||
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromTensorflow, ZEND_FN(opencv_dnn_read_net_from_tensorflow), arginfo_void)
|
||||
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromONNX, ZEND_FN(opencv_dnn_read_net_from_onnx), arginfo_void)
|
||||
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromModelOptimizer, ZEND_FN(opencv_dnn_read_net_from_model_optimizer), arginfo_void)
|
||||
ZEND_NS_NAMED_FE(OPENCV_DNN_NS, readNetFromDarknet, ZEND_FN(opencv_dnn_read_net_from_darknet), arginfo_void)
|
||||
ZEND_NS_NAMED_FE(OPENCV_NS, imdecode, ZEND_FN(opencv_imdecode), arginfo_void)
|
||||
PHP_FE_END /* Must be the last line in opencv_functions[] */
|
||||
};
|
||||
|
||||
@@ -154,6 +154,81 @@ PHP_FUNCTION(opencv_dnn_read_net_from_tensorflow)
|
||||
RETURN_ZVAL(&instance,0,0);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_onnx)
|
||||
{
|
||||
char *filename;
|
||||
size_t filename_len;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
zval instance;
|
||||
object_init_ex(&instance, opencv_dnn_net_ce);
|
||||
opencv_dnn_net_object *obj = Z_PHP_DNN_NET_OBJ_P(&instance);
|
||||
obj->DNNNet = readNetFromONNX(filename);
|
||||
|
||||
RETURN_ZVAL(&instance,0,0);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_model_optimizer)
|
||||
{
|
||||
char *xml, *bin;
|
||||
size_t xml_len, bin_len;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &xml, &xml_len, &bin, &bin_len) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
ifstream xmlFile;
|
||||
xmlFile.open(xml);//open the input file
|
||||
stringstream xmlStream;
|
||||
xmlStream << xmlFile.rdbuf();//read the file
|
||||
string xmlData = xmlStream.str();
|
||||
|
||||
ifstream binFile;
|
||||
binFile.open(bin, ios::binary);//open the input file
|
||||
stringstream binStream;
|
||||
binStream << binFile.rdbuf();//read the file
|
||||
string binData = binStream.str();
|
||||
|
||||
zval instance;
|
||||
object_init_ex(&instance, opencv_dnn_net_ce);
|
||||
opencv_dnn_net_object *obj = Z_PHP_DNN_NET_OBJ_P(&instance);
|
||||
|
||||
obj->DNNNet = readNetFromModelOptimizer(xmlData, binData);
|
||||
|
||||
RETURN_ZVAL(&instance,0,0);
|
||||
}
|
||||
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_darknet)
|
||||
{
|
||||
char *cfg, *bin;
|
||||
size_t cfg_len, bin_len;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &cfg, &cfg_len, &bin, &bin_len) == FAILURE) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
ifstream cfgFile;
|
||||
cfgFile.open(cfg);//open the input file
|
||||
stringstream cfgStream;
|
||||
cfgStream << cfgFile.rdbuf();//read the file
|
||||
string cfgData = cfgStream.str();
|
||||
|
||||
ifstream binFile;
|
||||
binFile.open(bin, ios::binary);//open the input file
|
||||
stringstream binStream;
|
||||
binStream << binFile.rdbuf();//read the file
|
||||
string binData = binStream.str();
|
||||
|
||||
zval instance;
|
||||
object_init_ex(&instance, opencv_dnn_net_ce);
|
||||
opencv_dnn_net_object *obj = Z_PHP_DNN_NET_OBJ_P(&instance);
|
||||
|
||||
//obj->DNNNet = readNetFromDarknet(cfgData.c_str(), cfgData.size());
|
||||
obj->DNNNet = readNetFromDarknet(cfgData.c_str(), cfgData.size(), binData.c_str(), binData.size());
|
||||
|
||||
RETURN_ZVAL(&instance,0,0);
|
||||
}
|
||||
|
||||
PHP_METHOD(opencv_dnn_net, setInput)
|
||||
{
|
||||
zval *image_zval;
|
||||
|
||||
@@ -31,3 +31,6 @@ PHP_FUNCTION(opencv_dnn_blob_from_image);
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_torch);
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_caffe);
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_tensorflow);
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_onnx);
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_model_optimizer);
|
||||
PHP_FUNCTION(opencv_dnn_read_net_from_darknet);
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário