You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to python [keyword arguments](https://docs.python.org/3/glossary.html#term-argument) or c# [Named parameters](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments#named-arguments), keyword arguments free you from matching the order of arguments to the order of parameters in the parameter lists of called methods.
324
+
325
+
When a function has multiple default parameters, keyword arguments allows you to override only the needed parameters without specifying the previous default parameters.
326
+
327
+
As an example, given the documentation of [cv.normalize](https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga87eef7ee3970f86906d69a92cbf064bd)
For backwards compatibility, python still allow an old syntax for enums and call constructors. This library does not.
444
+
445
+
If you see in python
446
+
447
+
```python
448
+
cv.ml.SVM_create(...)
449
+
cv.ml.SVM_C_SVC
450
+
cv.TERM_CRITERIA_MAX_ITER
451
+
```
452
+
453
+
You should write in lua
454
+
455
+
```lua
456
+
cv.ml.SVM.create(...)
457
+
cv.ml.SVM.C_SVC
458
+
cv.TermCriteria.MAX_ITER
459
+
```
460
+
461
+
### Memory
462
+
463
+
Image processing can use up a lot of memory. Relying solely on the behaviour of the garbage collector can cause your program to consume more memory than necessary.
464
+
465
+
Therefore, think about calling `collectgarbage` in those cases.
466
+
467
+
```lua
468
+
localcap=cv.VideoCapture(0)
469
+
whiletruedo
470
+
-- Without this, memory grows indefinitely
471
+
collectgarbage()
472
+
473
+
localread, frame=cap:read()
474
+
cv.imshow("capture camera", frame)
475
+
ifcv.waitKey(0) ==0x1bthenbreakend
476
+
end
477
+
```
478
+
479
+
### Matrix manipulation
480
+
481
+
For maximum speed performance, when you need to manipulate matrices in lua, convert them `table`, do your manipulation and convert them back to matrices
482
+
483
+
```lua
484
+
-- transform into an lua table for faster processing in lua
0 commit comments