我们尝试从每个网络摄像机通过可可应用程序最好支持的分辨率捕获来自多个外部网络摄像机的图像。我们无法同时捕获所有提要点,即在所有网络摄像头上同时捕获,因为我们无法同时打开所有网络摄像头并调用捕获方法。以支持的图像分辨率在多个网络摄像机上同时捕获图像
我们已经成功地从每个摄像头拍摄支持的分辨率的图像,但仅在2张图像之间延迟3秒,因为我们正在分别为每个摄像头触发捕获过程。
我们有2个为这个应用程序非常具体的要求...捕获应该是一个摄像头支持最高分辨率的
- 图像。
- 从各种Feed中捕获的图像应该绝对没有时间延迟。
在支持的分辨率但3秒延时拍摄图像的源代码...
-(void)initailzeCamera{
if([cameraArray count] == 0) {
exit(1);
}
if(cameraCount >= [cameraArray count]){
cameraCount = 0;
}
if(videoDevice){
//[mCaptureSession stopRunning];
}
videoDevice = [cameraArray objectAtIndex:cameraCount];
if(![videoDevice isOpen])
[videoDevice open:nil];
if(!videoDevice) {
exit(1);
}
if(mCaptureDeviceInput){
[mCaptureDeviceInput release];
}
mCaptureDeviceInput = [[QTCaptureDeviceInput alloc] initWithDevice:videoDevice];
mCaptureSession = [[QTCaptureSession alloc] init];
[mCaptureSession addInput:mCaptureDeviceInput error:nil];
[mCaptureSession startRunning];
[mCaptureView setCaptureSession:mCaptureSession];
[mCaptureView setVideoPreviewConnection:[[mCaptureView availableVideoPreviewConnections] objectAtIndex:0]];
[mCaptureView setHidden:YES];
[mCaptureSession startRunning];
[self performSelector:@selector(stopCamera) withObject:nil afterDelay:2.0];
}
// This delegate method is called whenever the QTCaptureDecompressedVideoOutput receives a frame
- (CIImage *)view:(QTCaptureView *)view willDisplayImage:(CIImage *)image{
NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCIImage:image];
jpegData =[[bitmapRep representationUsingType:NSJPEGFileType properties:nil]retain];
return image;
}
-(void)stopCamera{
@try {
[mCaptureSession stopRunning];
NSString *path= [NSString stringWithFormat:@"%@",[locationLabel stringValue]];
NSString *imagePath=[[NSString stringWithFormat:@"%@",path] retain];
NSString *imageName=[NSString stringWithFormat:@"%@.jpg",[[[NSDate date]description] substringToIndex:19]];
imageName = [imageName stringByReplacingOccurrencesOfString:@":" withString:@"."];
NSString *appFile = [imagePath stringByAppendingPathComponent:imageName];
if(jpegData != nil){
if([jpegData writeToFile:[appFile stringByExpandingTildeInPath] atomically:YES]){
}else {
}
}
else {
NSException* jpegDataNullException= [NSException exceptionWithName:@"JpegDataNullException"
reason:@"jpegData null found"
userInfo:nil];
@throw jpegDataNullException;
}
cameraCount++;
if(!flagForPause){
if(cameraCount < [cameraArray count]){
[self performSelector:@selector(initailzeCamera) withObject:nil afterDelay:1.0];
}else{
if(flagForAutoMode){
[self performSelector:@selector(initailzeCamera) withObject:nil afterDelay:[timeREcquire intValue]-5];
}
}
}
}
@catch (NSException * e) {
}
}