Wtf does this syntax mean (CVI/opencv python)?
cv.warpPerspective(src, M, dsize[, dst[, flags[, borderMode[, borderValue]]]] ) ->dst
Does anyone know what are these random [
in between the parameter names?
Source: https://docs.opencv.org/4.x/da/d54/group__imgproc__transform.html#gaf73673a7e8e18ec6963e3774e6a94b8726 Replies
Like… deeply nested arrays? Lol
Judging by all the ]]] at the end
Yea, I assumed so. Sorry should have added this here too. This is completely the opposite of that:
Like it expects normal non nested params. And then there is that nonsense at the bottom?????
And this code works:
transformed_image = cv.warpPerspective(img, matrix, (width, height))
So I have no idea what to thinkLooking at this example here
https://docs.opencv.org/4.x/dd/d93/samples_2cpp_2image_alignment_8cpp-example.html#a38
I think it's bc dsize contains all of those sub variables
Idk if that matches up with the param signature….
dsize is a Size type that has numerous nested parameters maybe?
and flags is the first layer, which holds a borderMode flag, which then holds a border Value???
weird structure but that's my best guess hahaha
Yea, it is kind of a weird structure
Found another one in the meantime:
And this is how it also works:
resized_image = cv.resize(img, (scaled_width, scaled_height), cv.INTER_AREA)
I am so lost on this syntax
Maybe I will find out some day by learning pythonmaybe it's just fucked up syntax for default values?? lmfao
Hmmmmm
It means that the parameters are optional
ayyy I guess right
In the picture, I think the function signature at the top is C++ syntax, the one in the bottom being Python syntax
The reason why it works it's because the last argument,
(width, height)
is a tuple, and because the method expects src
, M
, and dsize
, then we know that the third argument is the value for dsize
, which I guess is defined as a tupleYea, though I am still confused by why they wrote it with the
[
They could have just said
cv.warpPerspective(src, M, dsize, flags, borderMode, borderValue)
fr fr, just odd documentation style ig
Ohhh, found another one in the wild:
https://nodejs.org/api/buffer.html#static-method-bufferbytelengthstring-encoding
I guess this is not an odd documentation style but actually means something
ah see, it makes sense like that
it was the nesting syntax that was weird yk
ohhhhh maybe the nesting meant that they had a different version for each variation of default variables?
func(a)
func(a,b)
func(a,b,c)
etc.
so they nest the syntax to indicate that
ig ??
lmfao
idk
Wait, this one still doesn't make sense to me. Why is the comma after the
[
Looks like the second argument is optionalah to imply that a second argument is optional
Maybe it signifies that in some weird way
yeah
Ahhhh
It all makes sense now
So in the previous ones, the arguments were optional
yess