質問編集履歴

2

追加事項

2020/05/13 00:11

投稿

chestnutforest
chestnutforest

スコア9

test CHANGED
File without changes
test CHANGED
@@ -28,21 +28,23 @@
28
28
 
29
29
  以下の写真はCVPixelBufferの0チャンネルにアクセスして、一度Mat形式にしてテスト用にUIImageにして表示してます。
30
30
 
31
+
32
+
31
- Mat形式画像生成arucoに入までの過程を示ておきます
33
+ 内容を見たところ、以下リンク同じような問題のようですが、提示さた解決案では解決しせんでし
34
+
35
+ iOS13.0から発生した問題らしくて、YUV形式のY成分の並びが順番通りではない事に由来するそうです。
36
+
37
+ https://stackoverflow.com/questions/58171534/why-is-yp-cb-cr-image-buffer-all-shuffled-in-ios-13
38
+
39
+
40
+
41
+
32
42
 
33
43
 
34
44
 
35
45
  ```Swift
36
46
 
37
47
  let pixelBuffer = frame.capturedImage
38
-
39
-
40
-
41
- cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
42
-
43
-
44
-
45
- // The first plane / channel (at index 0) is the grayscale plane
46
48
 
47
49
 
48
50
 
@@ -58,14 +60,6 @@
58
60
 
59
61
 
60
62
 
61
- std::vector<int> ids;
62
-
63
- std::vector<std::vector<cv::Point2f>> corners;
64
-
65
- cv::aruco::detectMarkers(mat,dictionary,corners,ids);
66
-
67
-
68
-
69
63
  ```
70
64
 
71
65
 

1

追加事項の追加

2020/05/13 00:11

投稿

chestnutforest
chestnutforest

スコア9

test CHANGED
File without changes
test CHANGED
@@ -20,4 +20,54 @@
20
20
 
21
21
 
22
22
 
23
+ ###追加
24
+
25
+ CVPixelBufferはYUV表色系を使っていて、それに関しては両面のカメラで共通です。
26
+
27
+ なので、前面か背面で同じ処理をして以下のような結果になるのは何かおかしいと思うのですが.....
28
+
29
+ 以下の写真はCVPixelBufferの0チャンネルにアクセスして、一度Mat形式にしてテスト用にUIImageにして表示してます。
30
+
31
+ Mat形式の画像生成とarucoに入れるまでの過程を示しておきます。
32
+
33
+
34
+
35
+ ```Swift
36
+
37
+ let pixelBuffer = frame.capturedImage
38
+
39
+
40
+
41
+ cv::Ptr<cv::aruco::Dictionary> dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
42
+
43
+
44
+
45
+ // The first plane / channel (at index 0) is the grayscale plane
46
+
47
+
48
+
49
+ CVPixelBufferLockBaseAddress(pixelBuffer, 0);
50
+
51
+ void *baseaddress = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
52
+
53
+ CGFloat width = CVPixelBufferGetWidth(pixelBuffer);
54
+
55
+ CGFloat height = CVPixelBufferGetHeight(pixelBuffer);
56
+
57
+ cv::Mat mat(height, width, CV_8UC1, baseaddress, 0);
58
+
59
+
60
+
61
+ std::vector<int> ids;
62
+
63
+ std::vector<std::vector<cv::Point2f>> corners;
64
+
65
+ cv::aruco::detectMarkers(mat,dictionary,corners,ids);
66
+
67
+
68
+
69
+ ```
70
+
71
+
72
+
23
73
  ![比較画像。画質については問題にしなくても大丈夫です](00ed8fb358e5c8864077b84da4fd8a34.jpeg)