if all you need in python is to “pass around” your cuda workspace vectors
(as in: A() produces it, B() consumes it, and noone tries to “peek into it” from python inbetween),
you could wrap it opaquely into some struct:
// the struct is exposed to python, the content not so !
struct CV_EXPORTS_W Workspace {
vector<uchar*> workspace;
};
CV_EXPORTS_W Ptr<Workspace> init_workspace() {
Ptr<Workspace> ws = makePtr<Workspace>();
// ... fill ws->workspace
return ws;
}
CV_EXPORTS_W bool imencode( const String& ext, InputArray img,
CV_OUT std::vector& buf,
const std::vector& params = std::vector(),
CV_IN Ptr<Workspace> workspace) {
// do something with workspace->workspace;
}
usage from python would be as simple as:
ws = init_workspace()
...
cv2.imencode(ext,buffer,params,ws)