質問編集履歴
2
追加事項
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,25 +13,22 @@
|
|
13
13
|
CVPixelBufferはYUV表色系を使っていて、それに関しては両面のカメラで共通です。
|
14
14
|
なので、前面か背面で同じ処理をして以下のような結果になるのは何かおかしいと思うのですが.....
|
15
15
|
以下の写真はCVPixelBufferの0チャンネルにアクセスして、一度Mat形式にしてテスト用にUIImageにして表示してます。
|
16
|
-
Mat形式の画像生成とarucoに入れるまでの過程を示しておきます。
|
17
16
|
|
17
|
+
内容を見たところ、以下のリンクと同じような問題のようですが、提示された解決案では解決しませんでした。
|
18
|
+
iOS13.0から発生した問題らしくて、YUV形式のY成分の並びが順番通りではない事に由来するそうです。
|
19
|
+
https://stackoverflow.com/questions/58171534/why-is-yp-cb-cr-image-buffer-all-shuffled-in-ios-13
|
20
|
+
|
21
|
+
|
22
|
+
|
18
23
|
```Swift
|
19
24
|
let pixelBuffer = frame.capturedImage
|
20
25
|
|
21
|
-
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
|
22
|
-
|
23
|
-
// The first plane / channel (at index 0) is the grayscale plane
|
24
|
-
|
25
26
|
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
|
26
27
|
void *baseaddress = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
|
27
28
|
CGFloat width = CVPixelBufferGetWidth(pixelBuffer);
|
28
29
|
CGFloat height = CVPixelBufferGetHeight(pixelBuffer);
|
29
30
|
cv::Mat mat(height, width, CV_8UC1, baseaddress, 0);
|
30
31
|
|
31
|
-
std::vector<int> ids;
|
32
|
-
std::vector<std::vector<cv::Point2f>> corners;
|
33
|
-
cv::aruco::detectMarkers(mat,dictionary,corners,ids);
|
34
|
-
|
35
32
|
```
|
36
33
|
|
37
34
|

|
1
追加事項の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,4 +9,29 @@
|
|
9
9
|
###質問
|
10
10
|
iphone前面カメラ(ARWorldTrackingConfiguration)でCVPixelBufferを取得してMatに変換した場合はまともなMatが得られるのですが、前面カメラ(ARFaceTrackingConfiguration)で取得したCVPixelBufferをMat形式に変換すると訳のわからない結果が得られます。これは何由来の問題でしょうか。また、どのようにすれば解決できますか。よろしくお願いします。
|
11
11
|
|
12
|
+
###追加
|
13
|
+
CVPixelBufferはYUV表色系を使っていて、それに関しては両面のカメラで共通です。
|
14
|
+
なので、前面か背面で同じ処理をして以下のような結果になるのは何かおかしいと思うのですが.....
|
15
|
+
以下の写真はCVPixelBufferの0チャンネルにアクセスして、一度Mat形式にしてテスト用にUIImageにして表示してます。
|
16
|
+
Mat形式の画像生成とarucoに入れるまでの過程を示しておきます。
|
17
|
+
|
18
|
+
```Swift
|
19
|
+
let pixelBuffer = frame.capturedImage
|
20
|
+
|
21
|
+
cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
|
22
|
+
|
23
|
+
// The first plane / channel (at index 0) is the grayscale plane
|
24
|
+
|
25
|
+
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
|
26
|
+
void *baseaddress = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
|
27
|
+
CGFloat width = CVPixelBufferGetWidth(pixelBuffer);
|
28
|
+
CGFloat height = CVPixelBufferGetHeight(pixelBuffer);
|
29
|
+
cv::Mat mat(height, width, CV_8UC1, baseaddress, 0);
|
30
|
+
|
31
|
+
std::vector<int> ids;
|
32
|
+
std::vector<std::vector<cv::Point2f>> corners;
|
33
|
+
cv::aruco::detectMarkers(mat,dictionary,corners,ids);
|
34
|
+
|
35
|
+
```
|
36
|
+
|
12
37
|

|