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#gaf73673a7e8e18ec6963e3774e6a94b87
26 Replies
the magic guy
the magic guy17mo ago
Like… deeply nested arrays? Lol Judging by all the ]]] at the end
Eakam
Eakam17mo ago
Yea, I assumed so. Sorry should have added this here too. This is completely the opposite of that:
Eakam
Eakam17mo ago
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 think
CaramelCorn
CaramelCorn17mo ago
I think it's bc dsize contains all of those sub variables
the magic guy
the magic guy17mo ago
Idk if that matches up with the param signature….
CaramelCorn
CaramelCorn17mo ago
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
Eakam
Eakam17mo ago
Yea, it is kind of a weird structure
Eakam
Eakam17mo ago
Found another one in the meantime:
Eakam
Eakam17mo ago
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 python
CaramelCorn
CaramelCorn17mo ago
maybe it's just fucked up syntax for default values?? lmfao
the magic guy
the magic guy17mo ago
Hmmmmm
sigma
sigma17mo ago
It means that the parameters are optional
CaramelCorn
CaramelCorn17mo ago
ayyy I guess right
sigma
sigma17mo ago
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 tuple
Eakam
Eakam17mo ago
Yea, 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)
CaramelCorn
CaramelCorn17mo ago
fr fr, just odd documentation style ig
Eakam
Eakam17mo ago
I guess this is not an odd documentation style but actually means something
CaramelCorn
CaramelCorn17mo ago
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
Eakam
Eakam17mo ago
Wait, this one still doesn't make sense to me. Why is the comma after the [ Looks like the second argument is optional
CaramelCorn
CaramelCorn17mo ago
ah to imply that a second argument is optional
Eakam
Eakam17mo ago
Maybe it signifies that in some weird way
CaramelCorn
CaramelCorn17mo ago
yeah
Eakam
Eakam17mo ago
Ahhhh It all makes sense now So in the previous ones, the arguments were optional
CaramelCorn
CaramelCorn17mo ago
yess
Want results from more Discord servers?
Add your server
More Posts
Why is my Oracle Group By script not grouping all the employee numbers together?I want to group by the employee number and the total amounts of sales the employee did. But the emplHow boring is Programming in the long run, (Career wise)? Yes this is a serious question.Is just going to be black interface screens, and coding exclusively? Sitting at a desk for 8 hours nhi can anyone teach me/ help me understand the functional analysis for DSA456 course LabsI am not getting good marks by the professor for my work so i wonder whats wrong , if anyone experieHow do you call a base template class function from a derived template class?so i have this dervied class setup and i want to call a base function from the derived class. So i uhow hard is oop345 on a scale of 1-10, 10 being the hardest.What's the difference between Newham and International academy? (for CPA/CPP)I applied for fall 2023 CPA/CPP at the Newham campus and just got an email that it is full. Only SIAanyone in their 3rd semester want to form a study group?havent had classemates irl since pre covid =/Why is my program saying I didn't implement my friend insertion operator?I'm getting a linker error, even though I'm pretty sure I implemented the friend operator correctly.Accepted to CPA, CYT, and CSN for May 2023 (Mature Student Status)Hello everyone, so I am 33 and want to go back to college. I have prior University education not relStarting at SIA summer 2023Heyy, Im an international student admitted at SIA computer programming for may 2023. Is there anythi