# GENX320 Custom Histogram Construction

**URL:** <https://forums.openmv.io/t/genx320-custom-histogram-construction/11136>\
**Category:** OpenMV Boards\
**Created:** [June 16, 2025, 6:07pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136 "2025-06-16T18:07:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 16, 2025, 6:07pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/1 "2025-06-16T18:07:24Z")

</div>

I was interested in building two separate histograms. Instead of accumulating all events into one snapshot, I want one histogram that accumulates all intensity increases and one that accumulates all intensity decreases. For my application, I want to compare the on vs off events in a more detailed way than just a maxed out sensor.set\_contrast.  
I am currently thinking I will create a new function in the firmware similar to snapshot and snapshot post-process that will accumulate the on/off events separately. Is there a better way to accomplish this? I saw in another thread there was a project to make the direct event stream more accessible. Will that be completed soon?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 16, 2025, 6:24pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/2 "2025-06-16T18:24:49Z")

</div>

Hi, I will be implementing support for direct stream mode before the end of the month and probably starting next week.

You’ll have a list of events as an NDARRAY and then you’ll be able to pass that to the Image() constructor to create an image.

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 16, 2025, 6:34pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/3 "2025-06-16T18:34:20Z")

</div>

Will the NDARRAY just be a 320x320 grid where at my preferred sampling rate, I request the full state of all pixels and convert it to an image? Will I be able to access the [x, y, polarity, timestamp] like the Prophesee kits?

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 16, 2025, 6:44pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/4 "2025-06-16T18:44:26Z")

</div>

Additionally, do you suspect any problems with attempting to process and store two histograms with one modified snapshot call? Will there be any issues with the timing?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 16, 2025, 6:46pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/5 "2025-06-16T18:46:31Z")

</div>

Here’s the implementation:

> <https://github.com/openmv/openmv/issues/2674#issuecomment-2913365418>
>
> Should we? Given the interest in this.

You will be able to create two histograms as you desire. You’ll have to split off positive and negative events though from each other.

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 16, 2025, 7:06pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/6 "2025-06-16T19:06:32Z")

</div>

I am a bit confused by that implementation. What triggers an update to the ndarray? Does the event buffer keep track of pixels that have no intensity changes? Additionally, does this maintain the “accumulation” utilized by the framebuffer system?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 16, 2025, 7:22pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/7 "2025-06-16T19:22:30Z")

</div>

It’s like this:

```auto
sensor.reset()
evt_buffer = np.zeros((2048, 6), dtype=np.uint16)

while True:
   evt_count = sensor.ioctl(sensor.IOCTL_GENX_READ_EVENT, evt_buffer)
   #.....
   img = image.Image(evt_buffer, format=EVENT_DATA)

```

You call the read event ioctl. This updates the ndarray with events. Then if you want an image from the events you pass it to the Image() constructor. Otherwise, you have the RAW events and you may do with them what you want.

Understand that with this interface, if you want to split the the histogram image into two you have to do that via code manually splitting events in the event ndarray.

The ndarray is [type, ts\_s, ts\_ms, ts\_us, x, y]. I can make the Image() call process all non-zero events into an image. So, by duplicating the ndarray and then zeroing events which you don’t want in one image you’ll get your desired result.

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 16, 2025, 7:39pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/8 "2025-06-16T19:39:10Z")

</div>

> [@kwagyeman](#):
>
> So, by duplicating the ndarray and then zeroing events which you don’t want in one image you’ll get your desired result.

I’m not sure about this. If a given pixel in a 5ms time frame received both an increase and a decrease in intensity, would each histogram reflect the presence of each? The ndarray is only as big as the event buffer, so wouldn’t only one of the histograms be updated with the latest intensity reading? I don’t want to separate the On/Off from the same capture, I want to save all presence of On/Off between captures.

I am reading through the firmware and am confused by how the current snapshot method accounts for accumulation. Does it record the event stream in snapshot and then adjust the grayscale pixel intensity by polarity\*contrast in snapshot\_post\_process?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 16, 2025, 7:59pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/9 "2025-06-16T19:59:01Z")

</div>

Hi, we currently run the camera in histogram mode where it generates the histogram for you and sends 8-bit values where the events have already been combined.

In event mode you get the actual events. This has to be post-processed to generate an image. I’m saying the new API will allow you to control how that’s done.

If you want to append the ndarray returned to another ndarray you can. You can accumulate events as long as you have RAM to store them.

> I am reading through the firmware and am confused by how the current snapshot method accounts for accumulation. Does it record the event stream in snapshot and then adjust the grayscale pixel intensity by polarity\*contrast in snapshot\_post\_process?

In event mode I have code to do this, but, we don’t use that mode right now. Instead we use histogram mode. Once I add the new ndarray event support the post-processing code will be moved to Image().

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 16, 2025, 8:20pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/10 "2025-06-16T20:20:11Z")

</div>

Understood. Thank you for the help!

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 17, 2025, 8:51pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/11 "2025-06-17T20:51:58Z")

</div>

I have been trying to build the firmware from source to turn off the histogram and recompile. I followed the instructions written out in docs/firmware.md as well as the amended instructions [here](https://forums.openmv.io/t/inquiry-about-fetching-event-data-from-genx320-with-openmv4-h7-plus/10880/2). I am running into the same “undefined” errors.

In another thread I saw it mentioned that the docker instructions are recommended, is there no way to get the Linux build to work? I am failing after the  
"make -j$(nproc) TARGET=\<TRAGET\_NAME\> " / “make TARGET=OPENMV4P -j”  
I tried different board names and it didn’t change anything.

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 17, 2025, 9:17pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/12 "2025-06-17T21:17:43Z")

</div>

I attempted the Docker compilation as well, I am getting very similar errors.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 17, 2025, 10:24pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/13 "2025-06-17T22:24:47Z")

</div>

Are you building with the latest firmware? I just turned off histogram mode and re-compiled and get no undefined issues. It would help to post them.

Anyway, I’ll be starting support for the event mode where you can get an ndarray of events very soon. I should be able to implement it next week.

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 18, 2025, 4:56pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/14 "2025-06-18T16:56:02Z")

</div>

My docker compilation is generating the following errors.

> Create /workspace/build/OPENMV\_RT1060/lib/micropython/flexram\_config.s  
> Create /workspace/build/OPENMV\_RT1060/lib/micropython/genhdr/pins.h  
> GEN /workspace/build/OPENMV\_RT1060/lib/micropython/genhdr/mpversion.h  
> GEN /workspace/build/OPENMV\_RT1060/lib/micropython/genhdr/qstr.i.last  
> ../../extmod/modtls\_mbedtls.c:45:10: fatal error: mbedtls/platform.h: No such file or directory  
> 45 | #include “mbedtls/platform.h”  
> | ^ ~~~~~~~~~~~~~~~~~~~  
> compilation terminated.  
> mbedtls/mbedtls\_port.c:35:10: fatal error: mbedtls/platform\_time.h: No such file or directory  
> 35 | #include “mbedtls/platform\_time.h”  
> | ^ ~~~~~~~~~~~~~~~~~~~~~~~~  
> compilation terminated.  
> ../../extmod/modcryptolib.c:64:10: fatal error: mbedtls/aes.h: No such file or directory  
> 64 | #include \<mbedtls/aes.h\>  
> | ^ ~~~~~~~~~~~~~~  
> compilation terminated.  
> ../../extmod/modhashlib.c:35:10: fatal error: mbedtls/version.h: No such file or directory  
> 35 | #include “mbedtls/version.h”  
> | ^ ~~~~~~~~~~~~~~~~~~  
> compilation terminated.

and ends with

> make[1]: \*\*\* [../../py/mkrules.mk:133: /workspace/build/OPENMV\_RT1060/lib/micropython/genhdr/qstr.i.last] Error 1  
> make[1]: \*\*\* Deleting file ‘/workspace/build/OPENMV\_RT1060/lib/micropython/genhdr/qstr.i.last’  
> make: \*\*\* [/workspace/ports/mimxrt/omv\_portconfig.mk:202: MICROPYTHON] Error 2  
> make: \*\*\* [Makefile:14: build-firmware] Error 2

Are the submodules not being updated and made correctly?

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 18, 2025, 5:05pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/15 "2025-06-18T17:05:54Z")

</div>

I am following the instructions at docs/firmware. My board is an rt1062.

> git clone [GitHub - openmv/openmv: OpenMV Camera Module](https://github.com/openmv/openmv.git) --depth=50  
> cd openmv/docker  
> make TARGET=OPENMV\_RT1060

This is what I am running, with docker open in the background.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 18, 2025, 8:09pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/16 "2025-06-18T20:09:27Z")

</div>

@iabdalkader?

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 23, 2025, 2:36pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/17 "2025-06-23T14:36:33Z")

</div>

I wonder if the firmware is attempting to access deprecated methods of the micropython library, or is making a deprecated reference to it more broadly.

---

<div class="post-metadata">

**Author:** ![eventual](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@eventual](https://forums.openmv.io/u/eventual)\
**Post date:** [June 24, 2025, 7:12pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/18 "2025-06-24T19:12:16Z")

</div>

Do you know if a fix is available? I saw a firmware update to the GENX320 was pushed today.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 24, 2025, 7:26pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/19 "2025-06-24T19:26:56Z")

</div>

I mean, I can compile the firmware myself. I don’t quite know what error you are running into. The build system works. Docker is also tested per build.

Anyway, I’m starting on the GENX320 changes now, if you don’t mind waiting till the end of the week I’ll be done with the feature shortly.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [June 25, 2025, 7:26pm UTC](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136/20 "2025-06-25T19:26:42Z")

</div>

Half way done on the changes already. Will be done by Thursday.

[Next page](https://forums.openmv.io/t/genx320-custom-histogram-construction/11136.md?page=2)
