Skip to content
Open
Binary file modified trik/ov7670/mxn_sensor/dsp_server/bin/dsp_server.xe674
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,12 @@ void clasterizeImage()

}

uint32_t __attribute__((always_inline)) GetImgColor(int _rowStart,
int _heightStep,
int _colStart,
int _widthStep)
uint32_t __attribute__((always_inline)) GetImgColor(int _rowStart,
int _heightStep,
int _colStart,
int _widthStep,
bool _isHSV,
uint32_t* _colorHSV)
{
uint32_t rgbResult = 0;
const uint64_t* restrict img = s_rgb888hsv;
Expand Down Expand Up @@ -404,11 +406,20 @@ void clasterizeImage()
int sat = cs_max * m_satScale;
int val = cv_max * m_valScale;

return HSVtoRGB(hue, sat, val);
if (_isHSV)
{
//_colorHSV = ((uint32_t)hue << 16) + ((uint32_t)sat << 8) + ((uint32_t)val);
}
//if (!isHSV)
return HSVtoRGB(hue, sat, val);
//else
}


uint32_t __attribute__((always_inline)) GetImgColor2(uint32_t _row, uint32_t _col, uint32_t _height, uint32_t _width)
uint32_t __attribute__((always_inline)) GetImgColor2(uint32_t _row,
uint32_t _col,
uint32_t _height,
uint32_t _width)
{
const uint32_t width = m_inImageDesc.m_width;
const uint32_t gap = width - _width;
Expand Down Expand Up @@ -442,13 +453,18 @@ void clasterizeImage()
subImg += gap;
}

// return h, s and v as h_max, s_max and _max with values
// return h, s and v as h_max, s_max and v_max with values
// scaled to be between 0 and 255.
int hue = ch_max * m_hueScale;
int sat = cs_max * m_satScale;
int val = cv_max * m_valScale;

return HSVtoRGB(hue, sat, val);
return ((uint32_t)hue << 16) + ((uint32_t)sat << 8) + ((uint32_t)val);


//if (!isHSV)
// return HSVtoRGB(hue, sat, val);
//else
}


Expand Down Expand Up @@ -477,6 +493,51 @@ void clasterizeImage()
}
}

uint32_t HSVtoRGB(uint32_t hsv)
{
const int pos = 100;

int H = ((hsv >> 16) & 0xFF);
int S = ((hsv >> 8) & 0xFF);
int V = (hsv & 0xFF);

uint32_t rgbResult;

float r = 0;
float g = 0;
float b = 0;

float h = H / 255.0f;
float s = S / 255.0f;
float v = V / 255.0f;

//getTrueSV(v ,s, v ,s);
v = v < 0.2 ? 0 : v;
s = s < 0.2 ? 0 : 1;

int i = h*6;
float f = h*6-i;
float p = v * (1 - s);
float q = v * (1 - f * s);
double t = v * (1 - (1 - f) * s);

switch(i % 6) {
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
case 5: r = v; g = p; b = q; break;
}

int ri = r*255;
int gi = g*255;
int bi = b*255;
rgbResult = ((int32_t)ri << 16) + ((int32_t)gi << 8) + ((int32_t)bi);

return rgbResult;
}

uint32_t HSVtoRGB(int H, int S, int V)
{
uint32_t rgbResult;
Expand Down Expand Up @@ -609,10 +670,11 @@ void clasterizeImage()
for(int i = 0; i < m_heightM; ++i) {
int colStart = 0;
for(int j = 0; j < m_widthN; ++j) {
resColor = GetImgColor2(rowStart, colStart, m_heightStep, m_widthStep);
fillImage(rowStart, colStart, _outImage, resColor);
_outArgs.outColor[counter++] = resColor;
colStart += m_widthStep;
resColor = GetImgColor2(rowStart, colStart, m_heightStep, m_widthStep);
_outArgs.outColor[counter++] = resColor;
resColor = HSVtoRGB(resColor);
fillImage(rowStart, colStart, _outImage, resColor);
colStart += m_widthStep;
}
rowStart += m_heightStep;
}
Expand Down
1 change: 1 addition & 0 deletions trik/ov7670/mxn_sensor/trik_vidtranscode_cv.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef struct TRIK_VIDTRANSCODE_CV_DynamicParams {
typedef struct TRIK_VIDTRANSCODE_CV_InArgsAlg {
XDAS_Int32 widthM;
XDAS_Int32 heightN;
XDAS_Bool isHSV;
} TRIK_VIDTRANSCODE_CV_InArgsAlg;

typedef struct TRIK_VIDTRANSCODE_CV_InArgs {
Expand Down