2014-02-24 20:18:30 +01:00
|
|
|
// *****************************************************************
|
|
|
|
// Delphi-OpenCV Demo
|
|
|
|
// Copyright (C) 2013 Project Delphi-OpenCV
|
|
|
|
// ****************************************************************
|
|
|
|
// Contributor:
|
|
|
|
// Laentir Valetov
|
|
|
|
// email:laex@bk.ru
|
|
|
|
// ****************************************************************
|
|
|
|
// You may retrieve the latest version of this file at the GitHub,
|
|
|
|
// located at git://github.com/Laex/Delphi-OpenCV.git
|
|
|
|
// ****************************************************************
|
|
|
|
// The contents of this file are used with permission, subject to
|
|
|
|
// the Mozilla Public License Version 1.1 (the "License"); you may
|
|
|
|
// not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at
|
|
|
|
// http://www.mozilla.org/MPL/MPL-1_1Final.html
|
|
|
|
//
|
|
|
|
// Software distributed under the License is distributed on an
|
|
|
|
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
// implied. See the License for the specific language governing
|
|
|
|
// rights and limitations under the License.
|
|
|
|
// *******************************************************************
|
|
|
|
|
|
|
|
unit uOCVIOProperties;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
Uses
|
|
|
|
System.Classes,
|
|
|
|
DesignEditors,
|
|
|
|
DesignIntf;
|
|
|
|
|
|
|
|
Type
|
|
|
|
TImageOperationProperty = class(TClassProperty)
|
|
|
|
public
|
|
|
|
function GetAttributes: TPropertyAttributes; override;
|
|
|
|
function GetValue: string; override;
|
|
|
|
procedure GetValues(Proc: TGetStrProc); override;
|
|
|
|
procedure SetValue(const Value: string); override;
|
|
|
|
end;
|
|
|
|
|
2014-05-07 13:14:32 +02:00
|
|
|
TImagePreprocessingProperty = class(TClassProperty)
|
|
|
|
public
|
|
|
|
function GetAttributes: TPropertyAttributes; override;
|
|
|
|
function GetValue: string; override;
|
|
|
|
procedure GetValues(Proc: TGetStrProc); override;
|
|
|
|
procedure SetValue(const Value: string); override;
|
|
|
|
end;
|
2014-02-24 20:18:30 +01:00
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
Uses
|
|
|
|
System.SysUtils,
|
|
|
|
System.TypInfo,
|
|
|
|
System.RTLConsts,
|
|
|
|
uOCVImageOperation,
|
|
|
|
uOCVTypes;
|
|
|
|
|
2014-05-06 21:13:57 +02:00
|
|
|
{TImageOperationProperty}
|
2014-02-24 20:18:30 +01:00
|
|
|
|
|
|
|
function TImageOperationProperty.GetAttributes: TPropertyAttributes;
|
|
|
|
begin
|
|
|
|
Result := inherited GetAttributes;
|
|
|
|
Result := Result - [paReadOnly] + [paValueList, paSortList, paRevertable, paVolatileSubProperties];
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TImageOperationProperty.GetValue: string;
|
|
|
|
begin
|
|
|
|
Result := GetRegisteredImageOperations.GetNameByClass(TocvImageOperation(GetOrdValue).ClassType);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TImageOperationProperty.GetValues(Proc: TGetStrProc);
|
|
|
|
var
|
2014-05-06 21:13:57 +02:00
|
|
|
I: Integer;
|
2014-02-24 20:18:30 +01:00
|
|
|
rIO: TRegisteredImageOperations;
|
|
|
|
begin
|
|
|
|
rIO := GetRegisteredImageOperations;
|
2014-05-06 21:13:57 +02:00
|
|
|
for I := 0 to rIO.Count - 1 do
|
|
|
|
Proc(rIO[I]);
|
2014-02-24 20:18:30 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TImageOperationProperty.SetValue(const Value: string);
|
|
|
|
Var
|
|
|
|
APropertiesClass: TocvImageOperationClass;
|
2014-05-07 13:14:32 +02:00
|
|
|
I: Integer;
|
2014-02-24 20:18:30 +01:00
|
|
|
AIntf: IocvEditorPropertiesContainer;
|
|
|
|
begin
|
2014-05-06 21:13:57 +02:00
|
|
|
APropertiesClass := GetRegisteredImageOperations.FindByName(Value);
|
2014-02-24 20:18:30 +01:00
|
|
|
if APropertiesClass = nil then
|
|
|
|
APropertiesClass := TocvImageOperationClass(GetRegisteredImageOperations.Objects[0]);
|
2014-05-06 21:13:57 +02:00
|
|
|
|
2014-05-07 13:14:32 +02:00
|
|
|
for I := 0 to PropCount - 1 do
|
|
|
|
if Supports(GetComponent(I), IocvEditorPropertiesContainer, AIntf) then
|
2014-02-24 20:18:30 +01:00
|
|
|
AIntf.SetPropertiesClass(APropertiesClass);
|
|
|
|
|
2014-05-06 21:13:57 +02:00
|
|
|
Modified;
|
2014-02-24 20:18:30 +01:00
|
|
|
end;
|
|
|
|
|
2014-05-07 13:14:32 +02:00
|
|
|
{TImagePreprocessingProperty}
|
|
|
|
|
|
|
|
function TImagePreprocessingProperty.GetAttributes: TPropertyAttributes;
|
|
|
|
begin
|
|
|
|
Result := inherited GetAttributes;
|
|
|
|
Result := Result - [paReadOnly] + [paValueList, paSortList, paRevertable, paVolatileSubProperties];
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TImagePreprocessingProperty.GetValue: string;
|
|
|
|
begin
|
|
|
|
Result := GetRegisteredImageOperations.GetNameByClass(TocvImageOperation(GetOrdValue).ClassType);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TImagePreprocessingProperty.GetValues(Proc: TGetStrProc);
|
|
|
|
begin
|
|
|
|
Proc('None');
|
|
|
|
Proc('Threshold');
|
|
|
|
Proc('AdaptiveThreshold');
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TImagePreprocessingProperty.SetValue(const Value: string);
|
|
|
|
Var
|
|
|
|
APropertiesClass: TocvImageOperationClass;
|
|
|
|
I: Integer;
|
|
|
|
AIntf: IocvEditorPropertiesContainer;
|
|
|
|
begin
|
|
|
|
APropertiesClass := GetRegisteredImageOperations.FindByName(Value);
|
|
|
|
if APropertiesClass = nil then
|
|
|
|
APropertiesClass := TocvImageOperationClass(GetRegisteredImageOperations.Objects[0]);
|
2014-02-24 20:18:30 +01:00
|
|
|
|
2014-05-07 13:14:32 +02:00
|
|
|
for I := 0 to PropCount - 1 do
|
|
|
|
if Supports(GetComponent(I), IocvEditorPropertiesContainer, AIntf) then
|
|
|
|
AIntf.SetPropertiesClass(APropertiesClass);
|
|
|
|
|
|
|
|
Modified;
|
|
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
2014-02-24 20:18:30 +01:00
|
|
|
|
2014-05-06 21:13:57 +02:00
|
|
|
RegisterPropertyEditor(TypeInfo(TocvCustomImageOperation), TocvImageOperation, 'Operation', TImageOperationProperty);
|
2014-05-07 13:14:32 +02:00
|
|
|
RegisterPropertyEditor(TypeInfo(TocvCustomImageOperation), TocvImageOperationCollectionItem, 'Operation',
|
|
|
|
TImageOperationProperty);
|
|
|
|
RegisterPropertyEditor(TypeInfo(TocvCustomImageOperation), TocvContoursOperation, 'Preprocessing', TImagePreprocessingProperty);
|
|
|
|
|
2014-05-06 21:13:57 +02:00
|
|
|
UnlistPublishedProperty(TocvImageOperation, 'OperationClassName');
|
|
|
|
UnlistPublishedProperty(TocvImageOperationCollectionItem, 'OperationClassName');
|
2014-05-07 13:14:32 +02:00
|
|
|
UnlistPublishedProperty(TocvContoursOperation, 'OperationClassName');
|
2014-02-24 20:18:30 +01:00
|
|
|
|
|
|
|
end.
|