Skip to content

Commit

Permalink
Added color convertion functions.
Browse files Browse the repository at this point in the history
Updated the test framework to support the new functions.
Corrected some issues in the tests.
  • Loading branch information
christophe0606 committed May 30, 2024
1 parent 52002df commit 0e3d0da
Show file tree
Hide file tree
Showing 68 changed files with 10,270 additions and 831 deletions.
8 changes: 8 additions & 0 deletions ARM.CMSIS-CV.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
<!-- CV sources (core) -->
<file category="source" name="Source/cannysobel.c"/>
<file category="source" name="Source/gaussian.c"/>
<file category="source" name="Source/arm_yuv420_to_gray8.c"/>
<file category="source" name="Source/arm_bgr_8U3C_to_gray8.c"/>
<file category="source" name="Source/arm_gray8_to_rgb24.c"/>
<file category="source" name="Source/arm_bgr_8U3C_to_rgb24.c"/>
<file category="source" name="Source/arm_cv_common.c"/>
<file category="source" name="Source/arm_yuv420_to_rgb24.c"/>
<file category="source" name="Source/arm_rgb24_to_gray8.c"/>

</files>
</component>

Expand Down
11 changes: 9 additions & 2 deletions Documentation/Doxygen/src/mainpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ This user manual describes the CMSIS CV software library, a suite of common comp

It is a work in progress that has just started. API is not yet stable and will evolve for a few releases.

The current kernels need some tuning for accuracy.

## License {#license}

The CMSIS-CV is provided free of charge under the [Apache 2.0 License](https://raw.githubusercontent.com/ARM-software/CMSIS-DSP/main/LICENSE).

## Features

The library is divided into a number of functions each covering a specific category:

- \ref colorTransform "Color Transformations"
- \ref linearFilter "Linear filters"
- \ref featureDetection "Feature detection"

2 changes: 1 addition & 1 deletion Include/arm_cv.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "arm_cv_types.h"

/**
* @defgroup colorTransform Color Transform
* @defgroup colorTransform Color Transformations
*/
#include "cv/color_transforms.h"

Expand Down
59 changes: 59 additions & 0 deletions Include/arm_cv_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* ----------------------------------------------------------------------
* Project: CMSIS CV Library
* Title: arm_cv_commonh.h
* Description: Common declarations for CMSIS-CV
*
*
* Target Processor: Cortex-M and Cortex-A cores
* -------------------------------------------------------------------- */
/*
* Copyright (C) 2014 ARM Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ARM_CV_COMMON_H
#define ARM_CV_COMMON_H

#include "arm_math_types.h"

#ifdef __cplusplus
extern "C"
{
#endif

#if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)

/*
Used to place some very small working memory into
fast memory (like TCM when available).
This memory is used for scatter / gather instructions on Helium.
*/
#ifndef CV_FAST_MEMORY
#define CV_FAST_MEMORY
#endif

CV_FAST_MEMORY
extern int8_t cv_sgbuf[16*3];

#endif

#ifdef __cplusplus
}
#endif

#endif

62 changes: 52 additions & 10 deletions Include/arm_cv_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ extern "C"
{
#endif

typedef uint8_t gray8_t;
typedef uint16_t gray16_t;
typedef uint8_t packed_rgb888_t;
typedef uint32_t rgba_t;
typedef uint8_t channel_uint8_t;
typedef uint8_t channel_uint16_t;


/**
Expand All @@ -58,7 +56,7 @@ typedef struct _arm_cv_image {
typedef struct _arm_cv_image_gray8 {
uint16_t width;
uint16_t height;
gray8_t* pData;
channel_uint8_t* pData;
} arm_cv_image_gray8_t;

/**
Expand All @@ -72,7 +70,7 @@ typedef struct _arm_cv_image_gray8 {
typedef struct _arm_cv_image_gray16 {
uint16_t width;
uint16_t height;
gray16_t* pData;
channel_uint16_t* pData;
} arm_cv_image_gray16_t;

/**
Expand All @@ -83,11 +81,11 @@ typedef struct _arm_cv_image_gray16 {
* @return
*
*/
typedef struct _arm_cv_image_rgb888 {
typedef struct _arm_cv_image_rgb24 {
uint16_t width;
uint16_t height;
packed_rgb888_t* pData;
} arm_cv_image_rgb888_t;
channel_uint8_t* pData;
} arm_cv_image_rgb24_t;

/**
* @brief Structure for a RGBA image
Expand All @@ -100,9 +98,53 @@ typedef struct _arm_cv_image_rgb888 {
typedef struct _arm_cv_image_rgba {
uint16_t width;
uint16_t height;
rgba_t* pData;
channel_uint8_t* pData;
} arm_cv_image_rgba_t;

/**
* @brief Structure for a unpacked YUV420 image
* @param width image width in pixels
* @param height image height in pixels
* @param pData pointer to the array containing the data for the pixels
* @return
*
* @par The image is unpacked
* There are 3 planes : Y, U and V
* width and height are the dimensions of the image and not of the
* tensor (different from OpenCV for instance)
* @par Format details
* - YUV = YCbCr
* - ITU-R BT.601 full format.
* @par Resulting output range is
* - Y=[16...235]
* - Cb (U) =[16...240]
* - Cr (V) =[16...240]
*
*/
typedef struct _arm_cv_image_yuv420 {
uint16_t width;
uint16_t height;
channel_uint8_t* pData;
} arm_cv_image_yuv420_t;

/**
* @brief Structure for a unpacked BGR image
* @param width image width in pixels
* @param height image height in pixels
* @param pData pointer to the array containing the data for the pixels
* @return
*
* @par The image is unpacked
* There are 3 planes : B,G,R
* width and height are the dimensions of the image and not of the
*
*/
typedef struct _arm_cv_image_bgr_8U3C {
uint16_t width;
uint16_t height;
channel_uint8_t* pData;
} arm_cv_image_bgr_8U3C_t;

/**
* @brief Structure for a q15 image
* @param width image width in pixels
Expand Down
1 change: 1 addition & 0 deletions Include/arm_cv_types_f16.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define ARM_CV_TYPES_F16_H

#include "arm_math_types_f16.h"
#include "arm_cv_types_f16.h"

#ifdef __cplusplus
extern "C"
Expand Down
82 changes: 81 additions & 1 deletion Include/cv/color_transforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,84 @@
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*/

#ifndef ARM_CV_COLOR_TRANSFORM_H
#define ARM_CV_COLOR_TRANSFORM_H


//this include contain the specific types of the library
#include "arm_cv_types.h"

#ifdef __cplusplus
extern "C"
{
#endif




/**
* @brief Unpacked YUV420 to Grayscale
*
* @param[in] ImageIn The input image
* @param ImageOut The output image
*/
extern void arm_yuv420_to_gray8(const arm_cv_image_yuv420_t* ImageIn,
arm_cv_image_gray8_t* ImageOut);

/**
* @brief Unpacked YUV420 to packed RGB24
*
* @param[in] ImageIn The input image
* @param ImageOut The output image
*/
extern void arm_yuv420_to_rgb24(const arm_cv_image_yuv420_t* ImageIn,
arm_cv_image_rgb24_t* ImageOut);


/**
* @brief Unpacked BGR 8U3C to Grayscale
*
* @param[in] ImageIn The input image
* @param ImageOut The output image
*/
extern void arm_bgr_8U3C_to_gray8(const arm_cv_image_bgr_8U3C_t* ImageIn,
arm_cv_image_gray8_t* ImageOut);


/**
* @brief Unpacked BGR 8U3C to RGB24
*
* @param[in] ImageIn The input image
* @param ImageOut The output image
*/
extern void arm_bgr_8U3C_to_rgb24(const arm_cv_image_bgr_8U3C_t* ImageIn,
arm_cv_image_rgb24_t* ImageOut);

/**
* @brief Grayscale to RGB24
*
* @param[in] ImageIn The input image
* @param ImageOut The output image
*/
extern void arm_gray8_to_rgb24(const arm_cv_image_gray8_t* ImageIn,
arm_cv_image_rgb24_t* ImageOut);



/**
* @brief Packed RGB24 to Grayscale
*
* @param[in] ImageIn The input image
* @param ImageOut The output image
*/
extern void arm_rgb24_to_gray8(const arm_cv_image_rgb24_t* ImageIn,
arm_cv_image_gray8_t* ImageOut);

#ifdef __cplusplus
}
#endif


#endif
10 changes: 9 additions & 1 deletion Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ add_library(CMSISCV STATIC)
target_include_directories(CMSISCV PUBLIC "${ROOT}/Include")

target_sources(CMSISCV PRIVATE cannysobel.c
gaussian.c)
gaussian.c
arm_yuv420_to_gray8.c
arm_bgr_8U3C_to_gray8.c
arm_gray8_to_rgb24.c
arm_bgr_8U3C_to_rgb24.c
arm_cv_common.c
arm_yuv420_to_rgb24.c
arm_rgb24_to_gray8.c
)

if (HOST)
target_compile_definitions(CMSISCV PUBLIC __GNUC_PYTHON__)
Expand Down
Loading

0 comments on commit 0e3d0da

Please sign in to comment.