Open
Description
Hi,
There is an issue with the remap function when using the CUDA version. Here's a script that runs the most boiled down version of the issue:
require 'torch'
require 'cutorch'
cv = require 'cv'
require 'cv.cudawarping'
require 'cv.imgcodecs'
require 'cv.highgui'
require 'cv.imgproc'
torch.setdefaulttensortype('torch.FloatTensor')
local function meshgrid(x,y)
local xx = torch.repeatTensor(x, y:size(1),1)
local yy = torch.repeatTensor(y:view(-1,1), 1, x:size(1))
return xx, yy
end
local sz = {32,32} -- desired size after interpolation
local csz = {8,8} -- original size to interpolate
--local csz = {2,2} -- this doesn't work... neither does 3x3 or 4x4
local im = torch.zeros(csz[1],csz[2]) -- create dummy image
im = im:cuda()
-- create new locations to sample the image
local wxxi = torch.linspace(0,csz[1]-1,sz[1])
local wyyi = torch.linspace(0,csz[2]-1,sz[2])
wxxi = wxxi:cuda()
wxxi = wyyi:cuda()
local wxx, wyy = meshgrid(wxxi,wyyi)
wxx = wxx:cuda()
wyy = wyy:cuda()
local imInterp = cv.cuda.remap{src=im, map1=wxx, map2=wyy, interpolation=cv.INTER_LINEAR, borderMode=cv.BORDER_CONSTANT, borderValue=0}
print('done!')
print(imInterp:size())
In the error log:
C++ exception
stack traceback:
[C]: in function 'remapCuda'
.../lib/torch/install/share/lua/5.1/cv/cudawarping/init.lua:64: in function 'remap'
temp_2.lua:33: in main chunk