Post

Replies

Boosts

Views

Activity

Why does calling AVCapturePhotoOutput.capturePhoto freeze preview(AVCaptureVideoDataOutput.captureOutput)
I am using AVCaptureVideoDataOutput to capture each frame from camera capture. I display these frame to MTKView. that's fine. If I call AVCapturePhotoOutput.capturePhoto, the delegate function AVCaptureVideoDataOutput.captureOutput will be paused, so that my preview had a little freezed, that's very bad. I don't know if I do something wrong cause this? this is my capturePhoto code: func createTakePhotoSettingForNormalPhoto() - AVCapturePhotoSettings { var settings: AVCapturePhotoSettings settings.isHighResolutionPhotoEnabled = true return settings } func takePhoto() { settings = createTakePhotoSettingForNormalPhoto() settings.flashMode = ... _outputStillImage.capturePhoto(with: settings, delegate: self) } I noticed that if I tap shot button repeatly and quickly in IOS native Camera APP, it will have a black flash at each shot, but the preview also could display frame smoothly.
0
0
1k
Mar ’21
Iphone12 pro record 4K 60FPS video always drop frame
I am using Iphone12 pro to test my camera app, when I record 4K 60FPS video, captureOutput didDrop will be invoked many times, the final fps only was about 45fps. I found some weird things. If I move camera or let something moving front of the camera, the viewport is changing, the dropping frame will stop, If keep camera stable and static, dropping frame will start again. I made some debug info displayed in the top of view, If I display it, the dropping frame stopped, If I hide this debug view, dropping frame start agian. If I don't record ( with AVAssetWriter) , it will drop frame per 0.5 sec, If I start record, it drop frame very fast. drop frame reason is "OutOfBuffers" this problem is must shown on iphone12 pro, everything is fine on iphoneX.
0
0
1.9k
Apr ’21
iOS 15.4 iphone12pro, iphone12pro max capture depth start session failed
recently, we recevied many portrait mode issue about camera couldn't be launched. there is the error report from Notification notification: name = AVCaptureSessionRuntimeErrorNotification, object = Optional(<AVCaptureSession: 0x282f5c830 [AVCaptureSessionPresetPhoto]> <AVCaptureDeviceInput: 0x282d1fc40 [Back Dual Cam]>[vide] -> <AVCapturePhotoOutput: 0x282d2adc0> <AVCaptureDeviceInput: 0x282d1fc40 [Back Dual Cam]>[vide] -> <AVCaptureVideoDataOutput: 0x282d26f40> <AVCaptureDeviceInput: 0x282d1fc40 [Back Dual Cam]>[dpth] -> <AVCaptureDepthDataOutput: 0x282d361a0>), userInfo = Optional([AnyHashable("AVCaptureSessionErrorKey"): Error Domain=AVFoundationErrorDomain Code=-11819 "The operation could not be completed" UserInfo={NSLocalizedDescription=The operation could not be completed, NSLocalizedRecoverySuggestion=}]) 2022-04-06 12:11:15.969 < i > Thread: main [CaptureManager] onAVCaptureSessionRuntimeError: related decl 'e' for AVError(_nsError: Error Domain=AVFoundationErrorDomain Code=-11819 "The operation could not be completed" UserInfo={NSLocalizedDescription=The operation could not be completed, NSLocalizedRecoverySuggestion=}) code: -11819 session.isRunning: false I don't know how to fix this, other device is ok in ios 15.4 we can't re produce this problem
0
0
805
Apr ’22
Playing a sound effect before record video makes video's sound volume is low
I am using AudioService API to play a sound effect before start video recoding, I found a weird thing that the final result video's volume is relative to sound effect volume. if sound effect volume is big, the final video's volume became so low, if sound effect volume is quite, final video's volume is big. I think the iphone's microphone or audio framework make this, maybe it detected the peak volume and balance audio record volume. I use 'playAndRecord' to record video, dosen't change it when play sound effect. need help to slove this issue, i want the video's volume is constants
0
0
792
Aug ’22
IOS 18: How to create a custom App 'Control' that could be display in Control List?
in ios 18, we can custom two bottom button on Lock Screen, in past, they are Flash and Camera. So I want my app's function could be display in here, and I custom it, and will show a Controls List, But I can not found my app's icon. How to make a myself Control item and add it to Control List? any guideline or tutorials are welcome :D
0
0
434
Sep ’24
Why doesn't sometimes recommendedVideoSettings have recommend settings?
I am talking about AVCaptureVideoDataOutput.recommendedVideoSettings. I found sometimes it return nil, there is my test result. hevc .mov with activeColorSpace sRGB 60FPS -> ok 120FPS -> ok hevc .mov with activeColorSpace displayP3_HLG 60FPS -> nil 120FPS -> nil h264 .mov 30FPS -> ok 60FPS -> nil 120FPS -> nil so, if you don't give a recommend setting, and you don't give a document, how does developer to use it?
0
0
402
Nov ’24
iphone 7 take RAW photo capture exception
iphone 7(iPhone9,2) take RAW photo capture crashed. raw pixel type is: 1919379252 processedFormat is hvc1 This error was throwed in photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) Error Domain=AVFoundationErrorDomain Code=-11800 "这项操作无法完成" UserInfo={NSUnderlyingError=0x12360ec60 {Error Domain=NSOSStatusErrorDomain Code=-16415 "(null)"}, NSLocalizedFailureReason=发生未知错误(-16415), AVErrorRecordingFailureDomainKey=4, NSLocalizedDescription=这项操作无法完成}
1
0
1k
Apr ’21
3d texture sampler problem
I am using a color lookup table to create a 3d texture, and use input color to find output color. but I found output color has some interrupt layer. Is this sampler sample 3d texture by using trilinear? This is my code for creating 3d texture the lutData is a array of r, g, b, a, r, g, b, a, .... lutSize is the lookup table size, it's 32 or 64. func create3DTextureFromLutData(lutData: [Float], lutSize: Int) - MTLTexture? {     let desc = MTLTextureDescriptor()     desc.textureType = .type3D     desc.pixelFormat = .rgba32Float     desc.width = lutSize     desc.height = lutSize     desc.depth = lutSize     desc.usage = .shaderRead           guard let texture = _device.makeTexture(descriptor: desc) else { return nil}           texture.replace(region: MTLRegion(origin: .init(x: 0, y: 0, z: 0), size: .init(width: lutSize, height: lutSize, depth: lutSize)), mipmapLevel: 0, slice: 0, withBytes: lutData, bytesPerRow: lutSize * MemoryLayoutFloat.size * 4, bytesPerImage: lutSize * lutSize * MemoryLayoutFloat.size * 4)           return texture   } and in my shader, I just want to sample it like this. metal constexpr sampler textureSampler = sampler(mag_filter::linear, min_filter::linear, mip_filter::linear, address::clamp_to_edge); half4 lutWith3dTexture(half4 inputColor, short lutSize, half lutStrength, texture3dfloat, access::sample lut3dTexture, sampler textureSampler) {   half4 originColor = inputColor;   float3 coor = float3(((inputColor.rgb * (lutSize - 1)) + 0.5) / lutSize);   half4 resultColor = half4(lut3dTexture.sample(textureSampler, coor));       return mix(originColor, resultColor, lutStrength); } I am trying different filter::xxxx didn't help anything.
1
0
1k
May ’21
sceneWillResignActive be called after app launched from CameraCaptureIntentCaptureIntent
I made a LockScreen ControlWidget with CameraCaptureIntent, but I found launch my main app from Control Widget, SceneDelegate will be called like below: sceneWillEnterForeground sceneDidBecomeActive sceneWillResignActive sceneDidBecomeActive sceneWillResignActive be called, is it normal? it make my app camera launch with a delay.
1
0
394
Nov ’24
in Metal, how to sync calculate result in kernel function?
I want use Metal kernel function to calculate histogram of a video frame(texture) some code in kernel function like this float gray = grayScale(rgbValue); int histogramIndex = int(clamp(gray, 0.0, 1.0) * 255); histogram[histogramIndex] += 1; it works, but there was some mistake, I sum up every item value in array histogram, the sum result is not equals to my texture pixel count. it's always less than total pixel count. so I think there must be a multi-thread sync problem. so how could I sync the kernel function? I know MPS provided a MPSImageHistogram to do this, It works well, I just want to calculate histogram on my pipeline. Thanks
2
0
1.5k
Mar ’21
UIImage.draw(in:) has a aliasing problem
I have a image with pixel size: 3024 * 3024 I have a custom UIView with logical size: 207 * 207, and layer.contentsScale is 3, so pixel size is 621 * 621. I want to draw this UIImage in my custom UIView, the code in draw(rect:) like this; var image: UIImage? { didSet { setNeedDisplay() } } override func draw(_ rect: CGRect) {     guard let ctx = UIGraphicsGetCurrentContext() else { return }     ctx.addRect(bounds)     ctx.setFillColor(UIColor.black.cgColor)     ctx.fillPath()           if var im = image {        let size = Math.getMaxSizeWithAspect(size: CGSize(width: bounds.width, height: bounds.height), radioWidthToHeight: im.size.width / im.size.height)        im.draw(in: CGRect(x: (bounds.width - size.width) / 2, y: (bounds.height - size.height) / 2, width: size.width, height: size.height)) } and the result is very bad, picture is aliasing, I tried much solution, but not work well. // not work list... ctx.setShouldAntialias(true) ctx.setAllowsAntialiasing(true) ctx.interpolationQuality = .high layer.allowsEdgeAntialiasing = true layer.minificationFilter = .trilinear
2
0
2.1k
Mar ’21