-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
291 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "imgcodecs_async.h" | ||
#include "core/types.h" | ||
|
||
CvStatus *Image_IMRead_Async(const char *filename, int flags, CvCallback_1 callback) { | ||
BEGIN_WRAP | ||
callback(new Mat{new cv::Mat(cv::imread(filename, flags))}); | ||
END_WRAP | ||
} | ||
|
||
CvStatus *Image_IMWrite_Async(const char *filename, Mat img, CvCallback_1 callback) { | ||
BEGIN_WRAP | ||
callback(new bool(cv::imwrite(filename, *img.ptr))); | ||
END_WRAP | ||
} | ||
|
||
CvStatus *Image_IMWrite_WithParams_Async( | ||
const char *filename, Mat img, VecInt params, CvCallback_1 callback | ||
) { | ||
BEGIN_WRAP | ||
callback(new bool(cv::imwrite(filename, *img.ptr, *params.ptr))); | ||
END_WRAP | ||
} | ||
|
||
CvStatus *Image_IMEncode_Async(const char *fileExt, Mat img, CvCallback_2 callback) { | ||
BEGIN_WRAP | ||
std::vector<uchar> buf; | ||
bool success = cv::imencode(fileExt, *img.ptr, buf); | ||
callback(new bool(success), new VecUChar{new std::vector<uchar>(buf)}); | ||
END_WRAP | ||
} | ||
|
||
CvStatus *Image_IMEncode_WithParams_Async( | ||
const char *fileExt, Mat img, VecInt params, CvCallback_2 callback | ||
) { | ||
BEGIN_WRAP | ||
std::vector<uchar> buf; | ||
bool success = cv::imencode(fileExt, *img.ptr, buf, *params.ptr); | ||
callback(new bool(success), new VecUChar{new std::vector<uchar>(buf)}); | ||
END_WRAP | ||
} | ||
|
||
CvStatus *Image_IMDecode_Async(VecUChar buf, int flags, CvCallback_1 callback) { | ||
BEGIN_WRAP | ||
auto m = cv::imdecode(*buf.ptr, flags); | ||
callback(new Mat{new cv::Mat(m)}); | ||
END_WRAP | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Created by Rainyl. | ||
Licensed: Apache 2.0 license. Copyright (c) 2024 Rainyl. | ||
*/ | ||
|
||
#ifndef CVD_IMGCODECS_ASYNC_H_ | ||
#define CVD_IMGCODECS_ASYNC_H_ | ||
|
||
#include "core/types.h" | ||
#include <stdbool.h> | ||
|
||
#ifdef __cplusplus | ||
#include <opencv2/opencv.hpp> | ||
extern "C" { | ||
#endif | ||
|
||
CvStatus *Image_IMRead_Async(const char *filename, int flags, CvCallback_1 callback); | ||
CvStatus *Image_IMWrite_Async(const char *filename, Mat img, CvCallback_1 callback); | ||
CvStatus * | ||
Image_IMWrite_WithParams_Async(const char *filename, Mat img, VecInt params, CvCallback_1 callback); | ||
CvStatus *Image_IMEncode_Async(const char *fileExt, Mat img, CvCallback_2 callback); | ||
CvStatus * | ||
Image_IMEncode_WithParams_Async(const char *fileExt, Mat img, VecInt params, CvCallback_2 callback); | ||
CvStatus *Image_IMDecode_Async(VecUChar buf, int flags, CvCallback_1 callback); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // CVD_IMGCODECS_ASYNC_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters