mirror of
https://github.com/openharmony/ai_engine.git
synced 2026-07-01 20:14:02 -04:00
seperate common data define
Change-Id: Ia5ba7f9e658904efedfc599cf851570a730698eb
This commit is contained in:
@@ -13,27 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup cr_sdk
|
||||
* @{
|
||||
*
|
||||
* @brief Defines the development tool functions, constants, and error codes for card rectification (CR).
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file cr_callback.h
|
||||
*
|
||||
* @brief Defines the callback for processing errors and prediction results of card rectification.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef CR_CALLBACK_H
|
||||
#define CR_CALLBACK_H
|
||||
#ifndef AI_CALLBACK_H
|
||||
#define AI_CALLBACK_H
|
||||
|
||||
namespace OHOS {
|
||||
namespace AI {
|
||||
@@ -43,7 +24,7 @@ public:
|
||||
/**
|
||||
* @brief Defines the destructor for the callback.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
virtual ~ICallback() = default;
|
||||
@@ -53,7 +34,7 @@ public:
|
||||
*
|
||||
* @param result Indicates the prediction result.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
virtual void OnDetectedResult(const int resultCode, const T &result) = 0;
|
||||
@@ -61,5 +42,5 @@ public:
|
||||
} // namespace AI
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // CR_CALLBACK_H
|
||||
/** @} */
|
||||
#endif // AI_CALLBACK_H
|
||||
/** @} */
|
||||
|
||||
@@ -16,20 +16,22 @@
|
||||
#ifndef AI_RETCODE_H
|
||||
#define AI_RETCODE_H
|
||||
|
||||
/**
|
||||
* Error code used to communicate between plugin SDK and apps.
|
||||
*/
|
||||
typedef enum {
|
||||
AI_RETCODE_SUCCESS = 0,
|
||||
AI_RETCODE_FAILURE = -1
|
||||
AI_RETCODE_SUCCESS = 0, /** Return code for an operation success */
|
||||
AI_RETCODE_FAILURE = -1, /** Return code for an operation failure */
|
||||
|
||||
AI_RETCODE_INIT_ERROR = 1001, /** Return code for an initialization error */
|
||||
AI_RETCODE_NULL_PARAM = 1002, /** Return code for a null parameter error */
|
||||
AI_RETCODE_DUPLICATE_INIT_ERROR = 1004, /** Return code for a duplicate initialization error */
|
||||
|
||||
AI_RETCODE_SERIALIZATION_ERROR = 2001, /** Return code for a serialization error */
|
||||
AI_RETCODE_UNSERIALIZATION_ERROR = 2002, /** Return code for a deserialization error */
|
||||
|
||||
AI_RETCODE_PLUGIN_EXECUTION_ERROR = 3001, /** Return code for a plugin execution error */
|
||||
AI_RETCODE_PLUGIN_SESSION_ERROR = 3002, /** Return code for a plugin session error */
|
||||
} AiRetCode;
|
||||
|
||||
typedef enum {
|
||||
PLUGIN_RETCODE_FAILURE = -1, /** Return code for an operation failure */
|
||||
PLUGIN_RETCODE_SUCCESS = 0, /** Return code for an operation success */
|
||||
PLUGIN_RETCODE_INIT_ERROR = 1001, /** Return code for an initialization error */
|
||||
PLUGIN_RETCODE_NULL_PARAM = 1002, /** Return code for a null parameter error */
|
||||
PLUGIN_RETCODE_DUPLICATE_INIT_ERROR = 1004, /** Return code for a duplicate initialization error */
|
||||
PLUGIN_RETCODE_SERIALIZATION_ERROR = 2001, /** Return code for a serialization error */
|
||||
PLUGIN_RETCODE_UNSERIALIZATION_ERROR = 2002, /** Return code for a deserialization error */
|
||||
PLUGIN_RETCODE_PLUGIN_EXECUTION_ERROR = 3001, /** Return code for a plugin execution error */
|
||||
PLUGIN_RETCODE_PLUGIN_SESSION_ERROR = 3002, /** Return code for a plugin session error */
|
||||
} PluginRetCode;
|
||||
#endif // AI_RETCODE_H
|
||||
#endif // AI_RETCODE_H
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AI {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*
|
||||
* @brief Defines the development tool functions, constants, and error codes for card rectification (CR).
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
*
|
||||
* @brief Defines the callback for processing errors and prediction results of card rectification.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@@ -36,17 +36,18 @@
|
||||
#define CR_CALLBACK_H
|
||||
|
||||
#include "cr_constants.h"
|
||||
#include "cr_retcode.h"
|
||||
#include "kits/ai_retcode.h"
|
||||
#include "kits/ai_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AI {
|
||||
template<>
|
||||
class ICallback {
|
||||
class ICallback<RectifyCardOutput> {
|
||||
public:
|
||||
/**
|
||||
* @brief Defines the destructor for the callback.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
virtual ~ICallback() = default;
|
||||
@@ -56,7 +57,7 @@ public:
|
||||
*
|
||||
* @param result Indicates the prediction result.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
virtual void OnDetectedResult(const int resultCode, const RectifyCardOutput &result) = 0;
|
||||
@@ -65,4 +66,4 @@ public:
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // CR_CALLBACK_H
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*
|
||||
* @brief Defines the development tool functions, constants and error codes for card rectification (CR).
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@@ -28,17 +28,15 @@
|
||||
*
|
||||
* @brief Defines the constants and, input and output formats for calling the card rectification plugin.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef CR_CONSTANTS_H
|
||||
#define CR_CONSTANTS_H
|
||||
|
||||
#include "cv/ai_image.h"
|
||||
#include "kits/cv/ai_image.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -49,7 +47,7 @@ namespace AI {
|
||||
*
|
||||
* it must match related_sessions in services/common/protocol/plugin_config/plugin_config_ini/cv_card_rectification.ini
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
const long long ALGORITHM_TYPE_VERSION_CR = 20001001;
|
||||
@@ -70,4 +68,4 @@ typedef struct {
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // CR_CONSTANTS_H
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*
|
||||
* @brief Defines the development tool functions, constants, and error codes for card rectification (CR).
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
@@ -28,15 +28,13 @@
|
||||
*
|
||||
* @brief Defines the development tool functions for card rectification.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef CR_SDK_H
|
||||
#define CR_SDK_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "cr_callback.h"
|
||||
#include "cr_constants.h"
|
||||
|
||||
@@ -52,9 +50,9 @@ public:
|
||||
* @brief Establishes a connection from the development tool to the AI server.
|
||||
*
|
||||
* @return Returns {@link CR_RETCODE_SUCCESS} if the operation is successful;
|
||||
* returns a non-zero error code defined by {@link CrRetCode} otherwise.
|
||||
* returns a non-zero error code defined by {@link PluginRetCode} otherwise.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t Prepare();
|
||||
@@ -65,9 +63,9 @@ public:
|
||||
* @param [in] input Indicates the input image.
|
||||
* @param [out] output Indicates the result.
|
||||
* @return Returns {@link CR_RETCODE_SUCCESS} if the operation is successful;
|
||||
* returns a non-zero error code defined by {@link CrRetCode} otherwise.
|
||||
* returns a non-zero error code defined by {@link PluginRetCode} otherwise.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t RectifyCardSync(const RectifyCardInput &input, RectifyCardOutput &output);
|
||||
@@ -78,20 +76,20 @@ public:
|
||||
* @param [in] input Indicates the input image.
|
||||
* @param [in] callback Indicates the specified callback.
|
||||
* @return Returns {@link CR_RETCODE_SUCCESS} if the operation is successful;
|
||||
* returns a non-zero error code defined by {@link CrRetCode} otherwise.
|
||||
* returns a non-zero error code defined by {@link PluginRetCode} otherwise.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t RectifyCardAsync(const RectifyCardInput &input, const ICallback &callback);
|
||||
int32_t RectifyCardAsync(const RectifyCardInput &input, const ICallback<RectifyCardOutput> &callback);
|
||||
|
||||
/**
|
||||
* @brief Destroys the loaded model and related resources.
|
||||
*
|
||||
* @return Returns {@link CR_RETCODE_SUCCESS} if the operation is successful;
|
||||
* returns a non-zero error code defined by {@link CrRetCode} otherwise.
|
||||
* returns a non-zero error code defined by {@link PluginRetCode} otherwise.
|
||||
*
|
||||
* @since 1.0
|
||||
* @since 2.2
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t Release();
|
||||
@@ -100,4 +98,4 @@ public:
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // CR_SDK_H
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
@@ -131,23 +131,23 @@ HWTEST_F(AieClientReliabilityTest, AieClientSyncReliabilityTest001, TestSize.Lev
|
||||
|
||||
ServiceDeadCb cb;
|
||||
int resultCode = AieClientInit(configInfo, clientInfo, algoInfo, &cb);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
DataInfo outputInfo;
|
||||
|
||||
resultCode = AieClientPrepare(clientInfo, algoInfo, inputInfo, outputInfo, nullptr);
|
||||
FreeDataInfo(outputInfo);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
resultCode = AieClientSyncProcess(clientInfo, algoInfo, inputInfo, outputInfo);
|
||||
FreeDataInfo(outputInfo);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
resultCode = AieClientRelease(clientInfo, algoInfo, inputInfo);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
resultCode = AieClientDestroy(clientInfo);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
time_t currentTime = GetCurTimeSec();
|
||||
if ((currentTime - asyncStart) >= TIME_TEST) {
|
||||
@@ -203,24 +203,24 @@ HWTEST_F(AieClientReliabilityTest, AieClientAsyncReliabilityTest001, TestSize.Le
|
||||
|
||||
ServiceDeadCb cb;
|
||||
int resultCode = AieClientInit(configInfo, clientInfo, algoInfo, &cb);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
ClientCallback callback;
|
||||
|
||||
DataInfo outputInfo;
|
||||
resultCode = AieClientPrepare(clientInfo, algoInfo, inputInfo, outputInfo, &callback);
|
||||
FreeDataInfo(outputInfo);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
resultCode = AieClientAsyncProcess(clientInfo, algoInfo, inputInfo);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
StepSleepMs(500);
|
||||
|
||||
resultCode = AieClientRelease(clientInfo, algoInfo, inputInfo);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
resultCode = AieClientDestroy(clientInfo);
|
||||
EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS);
|
||||
EXPECT_EQ(resultCode, RETCODE_SUCCESS);
|
||||
|
||||
time_t currentTime = GetCurTimeSec();
|
||||
if ((currentTime - asyncStart) >= TIME_TEST) {
|
||||
|
||||
Reference in New Issue
Block a user