Comments (5)
Thank you for your feedback!
- Would you happen to have more information on preallocating with Python? I found a reference but it appears to not have a good answer. It's definitely something that would be nice to do.
- We chose inline methods because we want the external interface for all subsystems, to be the command interface. While this does cause the subsystem to be longer, it also reduces the odds of the subsystem's rules being violated (things happening without being commanded). It's a discussion that we may reopen for more complex commands.
- We found the
RobotContainer
to not serve sufficient purpose for our needs at this time, given our use of maps as classes. After reconsidering based on your prompting, we have determined that the container setup may be useful for the map setup after all. It's something we're going to investigate, thank you.
from frc-2020.
Preallocating is just creating variables outside of the main loop. Basically, what you'd need to do is something like this:
img = np.zeros((height, width, 3), dtype = np.uint8)
hsv_img = np.zeros((height, width, 3), dtype = np.uint8)
binary_img = np.zeros((height, width, 3), dtype = np.uint8)
output_img = np.zeros((height, width, 3), dtype = np.uint8)
while True:
img = frame.get_data()
hsv_img = cv2.cvtColor(...)
etc.
However, for your imgfilter
function, you have to add args for the preallocated matrices so that you can modify them within the function.
from frc-2020.
In the example you give, you allocate memory - and then remove the reference to them when you assign a new value using =
. I'd just like to make sure that that's clear. Using OpenCV currently, there doesn't appear to be a way to pass in a buffer to write into.
from frc-2020.
Having ran some benchmarks, it does seem like what you say is true. I've also tried with np.copyto()
and arr[:] = ...
, and all 4 methods time pretty similarly. Sorry for the misunderstanding, I assumed that the image would be read into the preallocated array rather than assigning a new array.
from frc-2020.
No worries! In many situations it would definitely be good advice. The only reasons it isn't in this case, is that opencv doesn't provide a way to pass in a buffer for the output, and that Python uses reference variables.
For future readers:
What this means is that when you use x = y
, you make x and y refer to the exact same object, not two identical objects. For things like integers, or things that can't be modified in place, that's fine. But if you do it in a list, it can have surprising behavior. x = []; y = x; y.append(5); assert len(x) == 1
is correct, since x
and y
refer to the same list.
So in the example you gave above, opencv would construct a new buffer object, and then change hsv_img
to reference that buffer object, instead of filling the existing buffer. The other methods you showed (arr[:]
and np.copyto
) should actually be slightly slower, since they still construct/allocate the new buffer, and then spend extra time copying the values into the existing buffer.
from frc-2020.
Related Issues (20)
- Drive Subsystem HOT 1
- Intake Subsystem HOT 4
- Control Panel Subsystem HOT 2
- Vision Subsystem HOT 3
- Indexer Subsystem HOT 2
- More lift stuff HOT 3
- More Drive things to do HOT 4
- More Vision things to do HOT 1
- Logging HOT 1
- New Control Panel things to do HOT 1
- General programming things to do... HOT 1
- Documentation HOT 3
- Indexer: Fix duplicate commands HOT 1
- Team 3045 Code Review Party HOT 1
- Fix Master HOT 2
- Trim the fat 2021 HOT 1
- Update WPIlib
- Lift Subsystem HOT 4
- Shooter Subsystem HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from frc-2020.