On 26.11.2021 12:16, Ferhat Kurtulmuş wrote:
I am working on the DCV to make it compilable with the recent versions
of LDC, mir libraries, and stuff. I have not yet simply forked it to
work on it. I am including modules one by one for my convenience
instead. Hope, I am close to the end. Here is my temporary repo:
https://github.com/aferust/ddcv
I run into some problems with module convolution, especially the
function conv invoked by the below code which calls canny edge filter:
```
Image image = imread("lena.png");
auto slice = image.sliced.rgb2gray;
//auto equalized = slice.histEqualize(slice.flattened.calcHistogram);
slice.asImage.imshow("Original");
auto edge = slice.canny!ubyte(15);
edge.asImage.imshow("edge");
waitKey();
```
Somehow, the compiler fails in deducting the types. I need some help
from Ilya or other people familiar with mir.ndslice.
To reproduce it, download my repo and try to compile it as it is. There
is a main with the test code in the repo. Just be sure you have a
glfw3.dll/.so.
```
source\dcv\imgproc\filter.d(547,18): Error: template
`dcv.imgproc.convolution.conv` cannot deduce function from argument
types `!()(Slice!(ubyte*, 2LU, mir_slice_kind.contiguous),
Slice!(float*, 2LU, mir_slice_kind.contiguous), Slice!(float*, 2LU,
mir_slice_kind.contiguous), Slice!(float*, 2LU,
mir_slice_kind.contiguous), TaskPool)`
source\dcv\imgproc\filter.d(548,18): Error: template
`dcv.imgproc.convolution.conv` cannot deduce function from argument
types `!()(Slice!(ubyte*, 2LU, mir_sut, KernelTensor
kerlice_kind.contiguous), Slice!(float*, 2LU,
mir_slice_kind.contiguous), Slice!(float*, 2LU,
mir_slice_kind.contiguous), Slice!(float*, 2LU,
mir_slice_kind.contiguous), TaskPool)`
lice_kind.contiguous
source\dcv\imgproc\convolution.d(78,13): Candidate is:
`conv(alias bc = neumann, InputTensor, KernelTensor, MaskTensor =
KernelTensor)(InputTensor input, KernelTensor kernel, InputTensor
prealloc = InputTensor.init, MaskTensor mask = MaskTensor.init, TaskPool
pool = taskPool)` ut, KernelTensor ker
source\dcv\imgproc\filter.d(674,18): Error: template instance
`dcv.imgproc.filter.calcGradients!(Slice!(ubyte*, 2LU,
mir_slice_kind.contiguous), float)` error instantiating r instantiating
source\dcv\imgproc\filter.d(694,24): instantiated from here:
`canny!(ubyte, ubyte, mir_slice_kind.contiguous)`
source\app.d(48,34): instantiated from here: `canny!(ubyte,
ubyte, mir_slice_kind.contiguous)`
```
I tried explicitly passing template parameters in
dcv.imgproc.filter.calcGradients like below, but in that way, I am
getting some other compilation errors:
```
alias Empty2Type = Slice!(V*, 2LU, SliceKind.contiguous);
fx = input.conv(neumann, typeof(input), Empty2Type, Empty2Type)
(kx, emptySlice!(2LU, V), emptySlice!(2LU, V), pool);
fy = input.convinput.conv(neumann, typeof(input), Empty2Type, Empty2Type)
(ky, emptySlice!(2LU, V), emptySlice!(2LU, V), pool);
```
Thanks in advance!
Didn't test it, just read the error output. `conv` takes (InputTensor,
KernelTensor, InputTensor, MaskTensor = KernelTensor) but you pass to it
(InputTensor, KernelTensor, KernelTensor, KernelTensor) and InputTensor
!is KernelTensor.
InputTensor = Slice!(ubyte*, 2LU, mir_slice_kind.contiguous) and
KernelTensor = Slice!(float*, 2LU, mir_slice_kind.contiguous). The key
argument of slices is a pointee type - InputTensor pointee has ubyte
type and KernelTensor has float. I'm not sure this solves your problem
but at least I'd start from here.