我的iPhone 5S有前置摄像头输出问题,后置摄像头的会话分辨率相同。 AVCaptureSessionPreset352x288
的(kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
)和kCVPixelBufferPixelFormatTypeKey
设置。
我在苹果论坛上发现了一些关于确切问题的讨论,这里是链接:https://discussions.apple.com/message/23079639#23079639
有什么问题? 请帮忙。
良好的输出,后置摄像头。
Printing description of imageBuffer:
<CVPixelBuffer 0xd5e2f30 width=352 height=288 pixelFormat=420v iosurface=0xd80e724 planes=2>
<Plane 0 width=352 height=288 bytesPerRow=352>
<Plane 1 width=176 height=144 bytesPerRow=352>
<attributes=<CFBasicHash 0xd5c3710 [0x3bf18ad0]>{type = immutable dict, count = 1,
entries =>
1 : <CFString 0x3bf971b4 [0x3bf18ad0]>{contents = "PixelFormatDescription"} = <CFBasicHash 0xb9fce0 [0x3bf18ad0]>{type = immutable dict, count = 7,
entries =>
0 : <CFString 0x3bf97164 [0x3bf18ad0]>{contents = "IOSurfaceCoreAnimationCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
2 : <CFString 0x3bf97194 [0x3bf18ad0]>{contents = "OpenGLESCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
3 : <CFString 0x3bf972c4 [0x3bf18ad0]>{contents = "ContainsAlpha"} = <CFBoolean 0x3bf18e88 [0x3bf18ad0]>{value = false}
5 : <CFString 0x3bf97184 [0x3bf18ad0]>{contents = "IOSurfaceOpenGLESFBOCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
7 : <CFString 0x3bf972d4 [0x3bf18ad0]>{contents = "Planes"} = <CFArray 0xb24830 [0x3bf18ad0]>{type = mutable-small, count = 2, values = (
0 : <CFBasicHash 0xb99420 [0x3bf18ad0]>{type = mutable dict, count = 3,
entries =>
0 : <CFString 0x3bf973b4 [0x3bf18ad0]>{contents = "FillExtendedPixelsCallback"} = <CFData 0xba06a0 [0x3bf18ad0]>{length = 12, capacity = 12, bytes = 0x00000000917cbb3100000000}
1 : <CFString 0x3bf97334 [0x3bf18ad0]>{contents = "BlackBlock"} = <CFData 0xb9deb0 [0x3bf18ad0]>{length = 1, capacity = 1, bytes = 0x10}
2 : <CFString 0x3bf97324 [0x3bf18ad0]>{contents = "BitsPerBlock"} = <CFNumber 0xb277e0 [0x3bf18ad0]>{value = +8, type = kCFNumberSInt32Type}
}
1 : <CFBasicHash 0xba0e50 [0x3bf18ad0]>{type = mutable dict, count = 5,
entries =>
0 : <CFString 0x3bf97334 [0x3bf18ad0]>{contents = "BlackBlock"} = <CFData 0xb9c550 [0x3bf18ad0]>{length = 2, capacity = 2, bytes = 0x8080}
2 : <CFString 0x3bf97344 [0x3bf18ad0]>{contents = "HorizontalSubsampling"} = <CFNumber 0xc0f720 [0x3bf18ad0]>{value = +2, type = kCFNumberSInt32Type}
4 : <CFString 0x3bf97324 [0x3bf18ad0]>{contents = "BitsPerBlock"} = <CFNumber 0xba0e80 [0x3bf18ad0]>{value = +16, type = kCFNumberSInt32Type}
5 : <CFString 0x3bf973b4 [0x3bf18ad0]>{contents = "FillExtendedPixelsCallback"} = <CFData 0xba16d0 [0x3bf18ad0]>{length = 12, capacity = 12, bytes = 0x00000000817bbb3100000000}
6 : <CFString 0x3bf97354 [0x3bf18ad0]>{contents = "VerticalSubsampling"} = <CFNumber 0xc0f720 [0x3bf18ad0]>{value = +2, type = kCFNumberSInt32Type}
}
)}
8 : <CFString 0x3bf97294 [0x3bf18ad0]>{contents = "PixelFormat"} = <CFNumber 0xb7acf0 [0x3bf18ad0]>{value = +875704438, type = kCFNumberSInt32Type}
12 : <CFString 0x3bf97174 [0x3bf18ad0]>{contents = "IOSurfaceOpenGLESTextureCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
}
}
propagatedAttachments=<CFBasicHash 0x126e2130 [0x3bf18ad0]>{type = mutable dict, count = 4,
entries =>
1 : <CFString 0x3bf70edc [0x3bf18ad0]>{contents = "MetadataDictionary"} = <CFBasicHash 0xd5da1a0 [0x3bf18ad0]>{type = mutable dict, count = 7,
entries =>
0 : <CFString 0x3bf70f4c [0x3bf18ad0]>{contents = "SNR"} = <CFNumber 0xd5da1d0 [0x3bf18ad0]>{value = +33.11550123401803347178, type = kCFNumberFloat64Type}
2 : <CFString 0x3bf70ddc [0x3bf18ad0]>{contents = "sensorDGain"} = <CFNumber 0xd58def0 [0x3bf18ad0]>{value = +256, type = kCFNumberSInt32Type}
3 : <CFString 0x3bf70f3c [0x3bf18ad0]>{contents = "SensorID"} = <CFNumber 0x126f7b40 [0x3bf18ad0]>{value = +356, type = kCFNumberSInt32Type}
6 : <CFString 0x3bf7054c [0x3bf18ad0]>{contents = "ExposureTime"} = <CFNumber 0xd5d83d0 [0x3bf18ad0]>{value = +0.03332500000000000046, type = kCFNumberFloat64Type}
7 : <CFString 0x3bf70dec [0x3bf18ad0]>{contents = "ispDGain"} = <CFNumber 0xd54d620 [0x3bf18ad0]>{value = +273, type = kCFNumberSInt32Type}
11 : <CFString 0x3bf7017c [0x3bf18ad0]>{contents = "AGC"} = <CFNumber 0xd5e21f0 [0x3bf18ad0]>{value = +780, type = kCFNumberSInt32Type}
12 : <CFString 0x3bf7114c [0x3bf18ad0]>{contents = "AEAverage"} = <CFNumber 0xd5e27a0 [0x3bf18ad0]>{value = +126, type = kCFNumberSInt32Type}
}
3 : <CFString 0x3bf96f54 [0x3bf18ad0]>{contents = "CVImageBufferYCbCrMatrix"} = <CFString 0xd5c34b0 [0x3bf18ad0]>{contents = "ITU_R_601_4"}
5 : <CFString 0x3bf96f94 [0x3bf18ad0]>{contents = "CVImageBufferColorPrimaries"} = <CFString 0x126bced0 [0x3bf18ad0]>{contents = "ITU_R_709_2"}
6 : <CFString 0x3bf96fd4 [0x3bf18ad0]>{contents = "CVImageBufferTransferFunction"} = <CFString 0xd58dfa0 [0x3bf18ad0]>{contents = "ITU_R_709_2"}
}
nonPropagatedAttachments=<CFBasicHash 0x126e2100 [0x3bf18ad0]>{type = mutable dict, count = 0,
entries =>
}
>
输出不良,前置摄像头。
Printing description of imageBuffer:
<CVPixelBuffer 0x12638980 width=352 height=288 pixelFormat=420v iosurface=0xd80e724 planes=2>
<Plane 0 width=352 height=288 bytesPerRow=384>
<Plane 1 width=176 height=144 bytesPerRow=384>
<attributes=<CFBasicHash 0x12638bb0 [0x3bf18ad0]>{type = immutable dict, count = 1,
entries =>
1 : <CFString 0x3bf971b4 [0x3bf18ad0]>{contents = "PixelFormatDescription"} = <CFBasicHash 0xb9fce0 [0x3bf18ad0]>{type = immutable dict, count = 7,
entries =>
0 : <CFString 0x3bf97164 [0x3bf18ad0]>{contents = "IOSurfaceCoreAnimationCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
2 : <CFString 0x3bf97194 [0x3bf18ad0]>{contents = "OpenGLESCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
3 : <CFString 0x3bf972c4 [0x3bf18ad0]>{contents = "ContainsAlpha"} = <CFBoolean 0x3bf18e88 [0x3bf18ad0]>{value = false}
5 : <CFString 0x3bf97184 [0x3bf18ad0]>{contents = "IOSurfaceOpenGLESFBOCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
7 : <CFString 0x3bf972d4 [0x3bf18ad0]>{contents = "Planes"} = <CFArray 0xb24830 [0x3bf18ad0]>{type = mutable-small, count = 2, values = (
0 : <CFBasicHash 0xb99420 [0x3bf18ad0]>{type = mutable dict, count = 3,
entries =>
0 : <CFString 0x3bf973b4 [0x3bf18ad0]>{contents = "FillExtendedPixelsCallback"} = <CFData 0xba06a0 [0x3bf18ad0]>{length = 12, capacity = 12, bytes = 0x00000000917cbb3100000000}
1 : <CFString 0x3bf97334 [0x3bf18ad0]>{contents = "BlackBlock"} = <CFData 0xb9deb0 [0x3bf18ad0]>{length = 1, capacity = 1, bytes = 0x10}
2 : <CFString 0x3bf97324 [0x3bf18ad0]>{contents = "BitsPerBlock"} = <CFNumber 0xb277e0 [0x3bf18ad0]>{value = +8, type = kCFNumberSInt32Type}
}
1 : <CFBasicHash 0xba0e50 [0x3bf18ad0]>{type = mutable dict, count = 5,
entries =>
0 : <CFString 0x3bf97334 [0x3bf18ad0]>{contents = "BlackBlock"} = <CFData 0xb9c550 [0x3bf18ad0]>{length = 2, capacity = 2, bytes = 0x8080}
2 : <CFString 0x3bf97344 [0x3bf18ad0]>{contents = "HorizontalSubsampling"} = <CFNumber 0xc0f720 [0x3bf18ad0]>{value = +2, type = kCFNumberSInt32Type}
4 : <CFString 0x3bf97324 [0x3bf18ad0]>{contents = "BitsPerBlock"} = <CFNumber 0xba0e80 [0x3bf18ad0]>{value = +16, type = kCFNumberSInt32Type}
5 : <CFString 0x3bf973b4 [0x3bf18ad0]>{contents = "FillExtendedPixelsCallback"} = <CFData 0xba16d0 [0x3bf18ad0]>{length = 12, capacity = 12, bytes = 0x00000000817bbb3100000000}
6 : <CFString 0x3bf97354 [0x3bf18ad0]>{contents = "VerticalSubsampling"} = <CFNumber 0xc0f720 [0x3bf18ad0]>{value = +2, type = kCFNumberSInt32Type}
}
)}
8 : <CFString 0x3bf97294 [0x3bf18ad0]>{contents = "PixelFormat"} = <CFNumber 0xb7acf0 [0x3bf18ad0]>{value = +875704438, type = kCFNumberSInt32Type}
12 : <CFString 0x3bf97174 [0x3bf18ad0]>{contents = "IOSurfaceOpenGLESTextureCompatibility"} = <CFBoolean 0x3bf18e80 [0x3bf18ad0]>{value = true}
}
}
propagatedAttachments=<CFBasicHash 0x12638c10 [0x3bf18ad0]>{type = mutable dict, count = 4,
entries =>
1 : <CFString 0x3bf70edc [0x3bf18ad0]>{contents = "MetadataDictionary"} = <CFBasicHash 0x12638650 [0x3bf18ad0]>{type = mutable dict, count = 7,
entries =>
0 : <CFString 0x3bf70f4c [0x3bf18ad0]>{contents = "SNR"} = <CFNumber 0x126367e0 [0x3bf18ad0]>{value = +34.16280207318401096472, type = kCFNumberFloat64Type}
2 : <CFString 0x3bf70ddc [0x3bf18ad0]>{contents = "sensorDGain"} = <CFNumber 0x12633120 [0x3bf18ad0]>{value = +256, type = kCFNumberSInt32Type}
3 : <CFString 0x3bf70f3c [0x3bf18ad0]>{contents = "SensorID"} = <CFNumber 0x126360c0 [0x3bf18ad0]>{value = +38754, type = kCFNumberSInt32Type}
6 : <CFString 0x3bf7054c [0x3bf18ad0]>{contents = "ExposureTime"} = <CFNumber 0x12636440 [0x3bf18ad0]>{value = +0.02999900000000000136, type = kCFNumberFloat64Type}
7 : <CFString 0x3bf70dec [0x3bf18ad0]>{contents = "ispDGain"} = <CFNumber 0x12630f20 [0x3bf18ad0]>{value = +260, type = kCFNumberSInt32Type}
11 : <CFString 0x3bf7017c [0x3bf18ad0]>{contents = "AGC"} = <CFNumber 0xd580830 [0x3bf18ad0]>{value = +1803, type = kCFNumberSInt32Type}
12 : <CFString 0x3bf7114c [0x3bf18ad0]>{contents = "AEAverage"} = <CFNumber 0x12635ae0 [0x3bf18ad0]>{value = +176, type = kCFNumberSInt32Type}
}
3 : <CFString 0x3bf96f54 [0x3bf18ad0]>{contents = "CVImageBufferYCbCrMatrix"} = <CFString 0x126383d0 [0x3bf18ad0]>{contents = "ITU_R_601_4"}
5 : <CFString 0x3bf96f94 [0x3bf18ad0]>{contents = "CVImageBufferColorPrimaries"} = <CFString 0x12632d90 [0x3bf18ad0]>{contents = "ITU_R_709_2"}
6 : <CFString 0x3bf96fd4 [0x3bf18ad0]>{contents = "CVImageBufferTransferFunction"} = <CFString 0x126372c0 [0x3bf18ad0]>{contents = "ITU_R_709_2"}
}
nonPropagatedAttachments=<CFBasicHash 0x12638be0 [0x3bf18ad0]>{type = mutable dict, count = 0,
entries =>
}
>
答案 0 :(得分:1)
正如Spectravideo328所提到的,每行的字节与图像的宽度不同。因此,您需要将有效数据从源图层复制到目标缓冲区,以跳过额外的填充。这意味着每行(等于图像的“高度”)复制第一个“宽度”字节数。