Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers.

Missing binding in python : rescaleCV

0 votes


I just played with new jevois-inventor and it's just amazing !! Great stuff indeed

Obviously, it becomes incredibly natural to add new python modules with that tool and I think I have discovered a missing binding in python that would be useful (at least in my app) : rescaleCv

when I do a pyhton jevois.rescaleCv(...) I get an error 'module libjevois' has no attribute rescaleCv

In think in file PythonSupport.C there is a missing


Or maybe I am making another mistake ?

If you confirm the function is not exported in python, glurk ... 

Adding the missing binding (supposing I have the proper fix) and then recompiling all jevois-sdk is a task out of my league ...

If the issue is confirmed, any trick , any workaround ?


asked Jun 22, 2018 in Programmer Questions by acharroux (140 points)

1 Answer

0 votes

oh, thanks, we will check and add the binding, but 1.8.1 is frozen now (compiling the debs rihght now...) so that will be for 1.8.2.

Now do not despair, jevois::rescaleCv() is only a trivial wrapper over cv::resize(), which just chooses a different interpolation method depending on whether we are upscaling or downscaling:

cv::Mat jevois::rescaleCv(cv::Mat const & img, cv::Size const & newdims)
  cv::Mat scaled;

  if (newdims.width == img.cols && newdims.height == img.rows)
    scaled = img;
  else if (newdims.width > img.cols || newdims.height > img.rows)
    cv::resize(img, scaled, newdims, 0, 0, cv::INTER_LINEAR);
    cv::resize(img, scaled, newdims, 0, 0, cv::INTER_AREA);

  return scaled;

so, in Python, you should be able to just do something along the lines of:

res = cv2.resize(img, (2*width, 2*height), interpolation = cv.INTER_CUBIC)

(I got that example from https://docs.opencv.org/3.4.0/da/d6e/tutorial_py_geometric_transformations.html )

answered Jun 22, 2018 by JeVois (38,620 points)
Great ! I did not understand it was a wrapper so tiny !!
Thx for the fast and accurate answer !!