Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions camera/api/isp.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

#include "statistics.h"

// black level is sensor dependant (used by horizontal filter)
#define BLACK_LEVEL 16

// ---------------------------------- AE/AGC ------------------------------

/**
Expand Down
2 changes: 1 addition & 1 deletion camera/src/image_hfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ void pixel_hfilter_update_scale(

const float sum_b = b0 + 2*b1;

state->acc_init = (128 * (sum_b - shift_scale - BLACK_LEVEL));
state->acc_init = 128 * (sum_b - shift_scale) - SENSOR_BLACK_LEVEL * shift_scale;
}
4 changes: 2 additions & 2 deletions sensors/api/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define camera_stop(iic) imx219_stream_stop(iic)
#define camera_configure(iic) imx219_configure_mode(iic)
#define camera_set_exposure(iic,ex) imx219_set_gain_dB(iic,ex)

#define SENSOR_BLACK_LEVEL 16
#endif

#if CONFIG_GC2145_SUPPORT
Expand All @@ -44,10 +44,10 @@
#define camera_stop(iic) gcstop(iic)
#define camera_configure(iic) gcconfigure(iic)
#define camera_set_exposure(iic,ex) gcsetexp(iic,ex)
#define SENSOR_BLACK_LEVEL 0
*/
#endif


// Modes configurations
#ifndef CONFIG_MODE
#error CONFIG_MODE has to be defined
Expand Down
48 changes: 28 additions & 20 deletions tests/unit_tests/src/test/pixel_hfilter_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,17 @@ TEST(pixel_hfilter, pixel_hfilter_update_scale__case1)
memset(&state, 0, sizeof(state));

const float gain = 0.0f;
const size_t offset = 0;

pixel_hfilter_update_scale(&state, gain, 0);
pixel_hfilter_update_scale(&state, gain, offset);

const unsigned exp_shift = 9;
const int32_t exp_acc_init = -128 * (1<<exp_shift);
const int32_t shift_scale = 1 << exp_shift;
const int32_t exp_acc_init = - 128 * shift_scale - SENSOR_BLACK_LEVEL * shift_scale;

TEST_ASSERT_EQUAL_INT8(0, state.coef[0]);
TEST_ASSERT_EQUAL_INT8(0, state.coef[2]);
TEST_ASSERT_EQUAL_INT8(0, state.coef[4]);
TEST_ASSERT_EQUAL_INT8(0, state.coef[0 + offset]);
TEST_ASSERT_EQUAL_INT8(0, state.coef[2 + offset]);
TEST_ASSERT_EQUAL_INT8(0, state.coef[4 + offset]);

TEST_ASSERT_EQUAL_UINT(exp_shift, state.shift);
TEST_ASSERT_EQUAL_INT32(exp_acc_init, state.acc_init);
Expand All @@ -296,15 +298,17 @@ TEST(pixel_hfilter, pixel_hfilter_update_scale__case2)
memset(&state, 0, sizeof(state));

const float gain = 1.0f;
const size_t offset = 1;

pixel_hfilter_update_scale(&state, gain, 1);
pixel_hfilter_update_scale(&state, gain, offset);

const unsigned exp_shift = 7;
const int32_t exp_acc_init = 0;
const int32_t shift_scale = 1 << exp_shift;
const int32_t exp_acc_init = - SENSOR_BLACK_LEVEL * shift_scale;

TEST_ASSERT_EQUAL_INT8(0x1B, state.coef[1]);
TEST_ASSERT_EQUAL_INT8(0x4B, state.coef[3]);
TEST_ASSERT_EQUAL_INT8(0x1B, state.coef[5]);
TEST_ASSERT_EQUAL_INT8(0x1B, state.coef[0 + offset]);
TEST_ASSERT_EQUAL_INT8(0x4B, state.coef[2 + offset]);
TEST_ASSERT_EQUAL_INT8(0x1B, state.coef[4 + offset]);

TEST_ASSERT_EQUAL_UINT(exp_shift, state.shift);
TEST_ASSERT_EQUAL_INT32(exp_acc_init, state.acc_init);
Expand All @@ -320,15 +324,17 @@ TEST(pixel_hfilter, pixel_hfilter_update_scale__case3)
memset(&state, 0, sizeof(state));

const float gain = 1.2f;
const size_t offset = 0;

pixel_hfilter_update_scale(&state, gain, 0);
pixel_hfilter_update_scale(&state, gain, offset);

const unsigned exp_shift = 7;
const int32_t exp_acc_init = 128 * (gain - 1.0f) * (1<<exp_shift);
const int32_t shift_scale = 1 << exp_shift;
const int32_t exp_acc_init = 128 * (gain - 1.0f) * shift_scale - SENSOR_BLACK_LEVEL * shift_scale;

TEST_ASSERT_EQUAL_INT8(0x20, state.coef[0]);
TEST_ASSERT_EQUAL_INT8(0x59, state.coef[2]);
TEST_ASSERT_EQUAL_INT8(0x20, state.coef[4]);
TEST_ASSERT_EQUAL_INT8(0x20, state.coef[0 + offset]);
TEST_ASSERT_EQUAL_INT8(0x59, state.coef[2 + offset]);
TEST_ASSERT_EQUAL_INT8(0x20, state.coef[4 + offset]);

TEST_ASSERT_EQUAL_UINT(exp_shift, state.shift);
TEST_ASSERT_EQUAL_INT32(exp_acc_init, state.acc_init);
Expand All @@ -344,15 +350,17 @@ TEST(pixel_hfilter, pixel_hfilter_update_scale__case4)
memset(&state, 0, sizeof(state));

const float gain = 0.8f;
const size_t offset = 1;

pixel_hfilter_update_scale(&state, gain, 1);
pixel_hfilter_update_scale(&state, gain, offset);

const unsigned exp_shift = 8;
const int32_t exp_acc_init = 128 * (gain - 1.0f) * (1<<exp_shift);
const int32_t shift_scale = 1 << exp_shift;
const int32_t exp_acc_init = 128 * (gain - 1.0f) * shift_scale - SENSOR_BLACK_LEVEL * shift_scale;

TEST_ASSERT_EQUAL_INT8(0x2B, state.coef[1]);
TEST_ASSERT_EQUAL_INT8(0x77, state.coef[3]);
TEST_ASSERT_EQUAL_INT8(0x2B, state.coef[5]);
TEST_ASSERT_EQUAL_INT8(0x2B, state.coef[0 + offset]);
TEST_ASSERT_EQUAL_INT8(0x77, state.coef[2 + offset]);
TEST_ASSERT_EQUAL_INT8(0x2B, state.coef[4 + offset]);

TEST_ASSERT_EQUAL_UINT(exp_shift, state.shift);
TEST_ASSERT_EQUAL_INT32(exp_acc_init, state.acc_init);
Expand Down