{"action":"created","issue":{"url":"https://api.github.com/repos/Itseez/opencv/issues/6078","repository_url":"https://api.github.com/repos/Itseez/opencv","labels_url":"https://api.github.com/repos/Itseez/opencv/issues/6078/labels{/name}","comments_url":"https://api.github.com/repos/Itseez/opencv/issues/6078/comments","events_url":"https://api.github.com/repos/Itseez/opencv/issues/6078/events","html_url":"https://github.com/Itseez/opencv/pull/6078","id":131980390,"number":6078,"title":"T-API python support implemented","user":{"login":"PolarNick239","id":1218605,"avatar_url":"https://avatars.githubusercontent.com/u/1218605?v=3","gravatar_id":"","url":"https://api.github.com/users/PolarNick239","html_url":"https://github.com/PolarNick239","followers_url":"https://api.github.com/users/PolarNick239/followers","following_url":"https://api.github.com/users/PolarNick239/following{/other_user}","gists_url":"https://api.github.com/users/PolarNick239/gists{/gist_id}","starred_url":"https://api.github.com/users/PolarNick239/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PolarNick239/subscriptions","organizations_url":"https://api.github.com/users/PolarNick239/orgs","repos_url":"https://api.github.com/users/PolarNick239/repos","events_url":"https://api.github.com/users/PolarNick239/events{/privacy}","received_events_url":"https://api.github.com/users/PolarNick239/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-07T16:06:47Z","updated_at":"2016-03-02T13:53:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Itseez/opencv/pulls/6078","html_url":"https://github.com/Itseez/opencv/pull/6078","diff_url":"https://github.com/Itseez/opencv/pull/6078.diff","patch_url":"https://github.com/Itseez/opencv/pull/6078.patch"},"body":"`cv2.UMat` implemented - python thin UMat wrapper\r\nNo implicit copy from GPU to Host done, resulting UMat can be passed to next function without overhead `cv2.UMat.get()` - to fetch data to Host\r\n\r\nNew tests covers: ORB, BFMatcher, goodFeaturesToTrack, calcOpticalFlowPyrLK\r\n\r\n**NB:** effective support for `vector<UMat>` was not implemented (`vector<Mat>` used).\r\n\r\n**Example** of usage:\r\n\r\n```python\r\nps, descs_umat = orb.detectAndCompute(cv2.UMat(img), None)\r\ndescs = descs_umat.get()\r\nmatcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)\r\nres = matcher.match(descs_umat, descs_umat)\r\n```\r\n\r\nFor more you can see [tests](https://github.com/PolarNick239/opencv/blob/9310f443c40a39b6a5de849d9154e85856df466f/modules/python/test/test.py#L158-L210)."},"comment":{"url":"https://api.github.com/repos/Itseez/opencv/issues/comments/191246462","html_url":"https://github.com/Itseez/opencv/pull/6078#issuecomment-191246462","issue_url":"https://api.github.com/repos/Itseez/opencv/issues/6078","id":191246462,"user":{"login":"alalek","id":4981219,"avatar_url":"https://avatars.githubusercontent.com/u/4981219?v=3","gravatar_id":"","url":"https://api.github.com/users/alalek","html_url":"https://github.com/alalek","followers_url":"https://api.github.com/users/alalek/followers","following_url":"https://api.github.com/users/alalek/following{/other_user}","gists_url":"https://api.github.com/users/alalek/gists{/gist_id}","starred_url":"https://api.github.com/users/alalek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alalek/subscriptions","organizations_url":"https://api.github.com/users/alalek/orgs","repos_url":"https://api.github.com/users/alalek/repos","events_url":"https://api.github.com/users/alalek/events{/privacy}","received_events_url":"https://api.github.com/users/alalek/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T13:53:32Z","updated_at":"2016-03-02T13:53:32Z","body":"@vpisarev There is an example of generated wrappers:\r\n\r\n```\r\nstatic PyObject* pyopencv_cv_Canny(PyObject* , PyObject* args, PyObject* kw)\r\n{\r\n    using namespace cv;\r\n\r\n    {\r\n    PyObject* pyobj_image = NULL;\r\n    Mat image;\r\n    PyObject* pyobj_edges = NULL;\r\n    Mat edges;\r\n    double threshold1=0;\r\n    double threshold2=0;\r\n    int apertureSize=3;\r\n    bool L2gradient=false;\r\n\r\n    const char* keywords[] = { \"image\", \"threshold1\", \"threshold2\", \"edges\", \"apertureSize\", \"L2gradient\", NULL };\r\n    if( PyArg_ParseTupleAndKeywords(args, kw, \"Odd|Oib:Canny\", (char**)keywords, &pyobj_image, &threshold1, &threshold2, &pyobj_edges, &apertureSize, &L2gradient) &&\r\n        pyopencv_to(pyobj_image, image, ArgInfo(\"image\", 0)) &&\r\n        pyopencv_to(pyobj_edges, edges, ArgInfo(\"edges\", 1)) )\r\n    {\r\n        ERRWRAP2(cv::Canny(image, edges, threshold1, threshold2, apertureSize, L2gradient));\r\n        return pyopencv_from(edges);\r\n    }\r\n    }\r\n    PyErr_Clear();\r\n\r\n    {\r\n    PyObject* pyobj_image = NULL;\r\n    UMat image;\r\n    PyObject* pyobj_edges = NULL;\r\n    UMat edges;\r\n    double threshold1=0;\r\n    double threshold2=0;\r\n    int apertureSize=3;\r\n    bool L2gradient=false;\r\n\r\n    const char* keywords[] = { \"image\", \"threshold1\", \"threshold2\", \"edges\", \"apertureSize\", \"L2gradient\", NULL };\r\n    if( PyArg_ParseTupleAndKeywords(args, kw, \"Odd|Oib:Canny\", (char**)keywords, &pyobj_image, &threshold1, &threshold2, &pyobj_edges, &apertureSize, &L2gradient) &&\r\n        pyopencv_to(pyobj_image, image, ArgInfo(\"image\", 0)) &&\r\n        pyopencv_to(pyobj_edges, edges, ArgInfo(\"edges\", 1)) )\r\n    {\r\n        ERRWRAP2(cv::Canny(image, edges, threshold1, threshold2, apertureSize, L2gradient));\r\n        return pyopencv_from(edges);\r\n    }\r\n    }\r\n\r\n    return NULL;\r\n}\r\n```\r\n\r\nUMat code path is used as a fallback if some parameters can't be used as Mat objects or invalid. It is not very effective, but it should not introduce significant performance impact to the original \"Mat\"-like code. Also there is no mixing of UMat/Mat object types (`mat = fn(umat, umat, mat)` uses all UMat for C++ function, return type is also forced to UMat).\r\n"}}