Comments (6)
maybe you can use image.Image()
now, this create a image with size 320x240 and RGB565 format
from maixpy-v1.
maybe you can use
image.Image()
now, this create a image with size 320x240 and RGB565 format
God, How to rewrite the following code with
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565) extra_fb.replace(sensor.snapshot())
from maixpy-v1.
@Neutree Can you send me an example of image.Image
usage because when I'm using as extra_fb = image.Image(size=(320, 240))
I'm getting out of heap memory error.
Even when I lower the resolution to 176, 120 error remains.
My goal is to use this openMV example: in_memory_basic_frame_differencing.py
Board is MaixCube.
from maixpy-v1.
@MIlan991 you can change gc size bigger by
from Maix import utils
utils.gc_heap_size(new_size)
default is 512*1024
from maixpy-v1.
@Neutree Thank you. I will try it. What is the maximum size I can set with MaixCube?
from maixpy-v1.
@Neutree I've given it a test but without success. Still getting the error even when heap size is increased to 2048*1024. The function that creates this error is img.get_histogram()
. When I remove that function everything works well.
Code:
# In Memory Basic Frame Differencing Example
#
# This example demonstrates using frame differencing with your OpenMV Cam. It's
# called basic frame differencing because there's no background image update.
# So, as time passes the background image may change resulting in issues.
import sensor, image, os
from Maix import utils
TRIGGER_THRESHOLD = 5
utils.gc_heap_size(2048 * 1024)
sensor.reset() # Reset and initialize the sensor. It will
# run automatically, call sensor.run(0) to stop
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QQQQVGA) # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.
print("About to save background image...")
gc.enable()
extra_fb = image.Image(size=(40, 30), copy_to_fb = False)
sensor.skip_frames(time = 2000) # Give the user time to get ready.
extra_fb.replace(sensor.snapshot())
print("Saved background image - Now frame differencing!")
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Take a picture and return the image.
# Replace the image with the "abs(NEW-OLD)" frame difference.
img.difference(extra_fb)
hist = img.get_histogram()
# This code below works by comparing the 99th percentile value (e.g. the
# non-outlier max value against the 90th percentile value (e.g. a non-max
# value. The difference between the two values will grow as the difference
# image seems more pixels change.
diff = hist.get_percentile(0.99).l_value() - hist.get_percentile(0.90).l_value()
triggered = diff > TRIGGER_THRESHOLD
print(clock.fps(), triggered, gc.mem_free()) # Note: Your OpenMV Cam runs about half as fast while
# connected to your computer. The FPS should increase once disconnected.
gc.collect()
from maixpy-v1.
Related Issues (20)
- Bug or other?
- ValueError: 【MAIXPY】kpu: load error:2009, ERR_MODELS_FULL: we only support load 5 models in the same time HOT 1
- how do I switch to the ov7740 camera sensor on my Sipeed Amigo in maixpy??? HOT 1
- find_line_segments freezes
- [QUESTION] How to use all cores?
- Another type of LCD or Camera.
- MemoryError: Out of Memory! Please reduce the resolution of the image you are running this algorithm on to bypass this issue!
- [MAIXPY]OSError:ERR_OUTPUTS_SET :kpu.set_outputs() to set shape
- IDE doesn't show video preview
- Problem when connecting Maixduino and MaixSenseA010 with uart
- 更新子模块时出错 HOT 3
- How to interprete custom object detection model
- maixpy doesnt recognize my board - m1s dock bl808 HOT 1
- MaixBit setting heap size with utils.gc_heap_size() no longer works HOT 1
- MAixPy IDE + MAix AMIGO y i e l d i n g ImportError: cannot import name MIC_ARRAY HOT 2
- Fail to install KFlash_py submodule (error on file .gitmodules) HOT 1
- How to convert .kmodel to .smodel.
- Fail to wake up from sleep in Maix Amigo - AXP173
- I2C Slave mode
- 请问Maixduino可以从Type-C口读数据吗?
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 maixpy-v1.