Skip to content

Commit ecea8ab

Browse files
committed
Processing optimization
1 parent 05dc4f6 commit ecea8ab

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Sources/KeypointDecoder/KeypointDecoder.mm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ -(void) run: (UIImage* ) uiImage
4444

4545
std::vector<float> keypoints;
4646

47+
cv::Mat image;
48+
UIImageToMat(uiImage, image);
49+
4750
for (int j = 0; j < num; ++j) {
4851

4952
std::vector<float> box = { _boxes[j*4], _boxes[j*4+1], _boxes[j*4+2], _boxes[j*4+3] };
5053
std::vector<float> center;
5154
std::vector<float> scale;
52-
CVPixelBufferRef pixelBuffer = preExecute(uiImage, box, modelWidth, modelHeight, center, scale);
55+
CVPixelBufferRef pixelBuffer = preExecute(image, box, modelWidth, modelHeight, center, scale);
5356

5457
DEBUG_MSG("center: " << center[0] << ", " << center[1] );
5558
DEBUG_MSG("scale: " << scale[0] << ", " << scale[1] );
@@ -65,17 +68,14 @@ -(void) run: (UIImage* ) uiImage
6568

6669
}
6770

68-
CVPixelBufferRef preExecute(UIImage* uiImage,
71+
CVPixelBufferRef preExecute(cv::Mat image,
6972
const std::vector<float> & box,
7073
int modelWidth, int modelHeight,
7174
std::vector<float> & center,
7275
std::vector<float> & scale)
7376
{
74-
cv::Mat image;
75-
UIImageToMat(uiImage, image);
76-
77-
float imageWidth = uiImage.size.width;
78-
float imageHeight = uiImage.size.height;
77+
float imageWidth = image.cols;
78+
float imageHeight = image.rows;
7979

8080
std::vector<float> _box(box);
8181
std::vector<float> image_size {imageHeight, imageWidth};

0 commit comments

Comments
 (0)