I get the message "objc[29459]: class `NSKVONotifying_AVCapturePhotoOutput' not linked into application" and I do not seem to be able to process a captured photo. Users on stackoverflow are seeing this too (using Swift): https://stackoverflow.com/questions/76893120/unable-to-capture-and-save-image-using-avcapturephotooutput-in-macos-app
I am running Ventura 13.0.1.
Minimal example:
#import <AVFoundation/AVFoundation.h>
@interface PhotoCaptureDelegate : NSObject <AVCapturePhotoCaptureDelegate>
@end
@implementation PhotoCaptureDelegate
- (void)captureOutput:(AVCapturePhotoOutput *)output didFinishProcessingPhoto:(AVCapturePhoto *)photo error:(nullable NSError *)error {
if (error) {
NSLog(@"Error capturing photo: %@", error.localizedDescription);
} else {
NSLog(@"Ready to process photo.");
}
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *captureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if (captureDevice) {
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error];
if (!error) {
[captureSession beginConfiguration];
[captureSession addInput:input];
AVCapturePhotoOutput *photoOutput = [[AVCapturePhotoOutput alloc] init];
[captureSession addOutput:photoOutput];
[captureSession commitConfiguration];
[captureSession startRunning];
// Create and configure a capture connection
AVCaptureConnection *connection = [photoOutput connectionWithMediaType:AVMediaTypeVideo];
if (connection) {
// Configure settings for the photo capture
AVCapturePhotoSettings *photoSettings = [AVCapturePhotoSettings photoSettings];
//[photoSettings setFlashMode:AVCaptureFlashModeAuto]; // Set the flash mode if needed
PhotoCaptureDelegate *photoCaptureDelegate = [[PhotoCaptureDelegate alloc] init];
[photoOutput capturePhotoWithSettings:photoSettings delegate:photoCaptureDelegate];
// Capture a photo and delegate will receive the result
}
} else {
NSLog(@"Error adding input: %@", error.localizedDescription);
}
} else {
NSLog(@"No video capture device available");
}
}
return 0;
}
Compile with:
$ clang -framework AVFoundation -framework Foundation -o test avphoto.m
Any thoughts?
Best regards,
Linus
Post
Replies
Boosts
Views
Activity
Hi,
The metal-cpp distribution appears to only contain headers for Foundation and Quartzcore. The LearnMetalCPP download [1] provides a ZIP with an metal-cpp-extensions directory containing AppKit.hpp and MetalKit.hpp headers. First question: Are these headers distributed anywhere else more publicly? Without these headers only the renderer can be fully written in C++ as far as I can tell, i.e. no complete C++ NSApplication. Second question: Will these headers, if needed, be maintained (e.g. updated and/or extended) by Apple along side metal-cpp?
[1] https://developer.apple.com/metal/cpp/
Thank you and regards.