1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
//
// Lynkeos
// $Id:$
//
// Created by Jean-Etienne LAMIAUD on 15/01/2014.
// Copyright 2014 Jean-Etienne LAMIAUD. All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#include <objc/runtime.h>
#include "MyImageStacker_Calibration.h"
static NSString * const myCalibrationImageStackerResult = @"CalibrationStackerResult";
/*!
* @abstract Result of the standard stacking strategy
*/
@interface CalibrationImageStackerResult : NSObject <LynkeosProcessingParameter>
{
@public
id <LynkeosImageBuffer> _stack; //!< Stack of calibration images
}
@end
@implementation CalibrationImageStackerResult
- (id) init
{
self = [super init];
if ( self != nil )
_stack = nil;
return( self );
}
- (void) dealloc
{
if ( _stack != nil )
[_stack release];
[super dealloc];
}
// This parameter is deleted at process end, it cannot be saved
- (void)encodeWithCoder:(NSCoder *)encoder
{
[self doesNotRecognizeSelector:_cmd];
}
- (id)initWithCoder:(NSCoder *)decoder
{
[self doesNotRecognizeSelector:_cmd];
return( nil );
}
@end
@implementation MyImageStacker_Calibration
- (id) init
{
if ( (self = [super init]) != nil )
{
_params = nil;
_stack = nil;
}
return( self );
}
- (id) initWithParameters: (id <NSObject>)params
list: (id <LynkeosImageList>)list
{
if ( (self = [self init]) != nil )
{
NSAssert1( [params isMemberOfClass:[MyImageStackerParameters class]],
@"Wrong parameter class %s for Image stacker (calibration)",
class_getName([params class]) );
_params = (MyImageStackerParameters*)[params retain];
}
return( self );
}
- (void) dealloc
{
if ( _stack != nil )
[_stack release];
[super dealloc];
}
- (void) processImage: (id <LynkeosImageBuffer>)image
{
// If this is the first image, set it into the stack
if ( _stack == nil )
_stack = [image retain];
// Otherwise accumulate
else
[_stack add:image];
}
- (void) finishOneProcessingThreadInList:(id <LynkeosImageList>)list ;
{
if ( _stack != nil )
{
// Accumulate intermediate results in the list
CalibrationImageStackerResult *res
= [list getProcessingParameterWithRef:myCalibrationImageStackerResult
forProcessing:myImageStackerRef];
if ( res == nil )
{
res = [[[CalibrationImageStackerResult alloc] init] autorelease];
res->_stack = [_stack retain];
[list setProcessingParameter:res withRef:myCalibrationImageStackerResult
forProcessing:myImageStackerRef];
}
else
[res->_stack add:_stack];
}
}
- (void) finishAllProcessingInList: (id <LynkeosImageList>)list;
{
// Retrieve the final stack
CalibrationImageStackerResult *res
= [list getProcessingParameterWithRef:myCalibrationImageStackerResult
forProcessing:myImageStackerRef];
if ( _stack != nil )
[_stack release];
_stack = [res->_stack retain];
// And get rid of the recombining parameter
[list setProcessingParameter:nil withRef:myCalibrationImageStackerResult
forProcessing:myImageStackerRef];
}
- (LynkeosStandardImageBuffer*) stackingResult { return( _stack ); }
@end
|