RandomTextImageGenerator DL
1 개요
- Random Text Image Generator DL은 FLImaging® 이미지에서 사용자가 설정한 파라미터에 따라 무작위적으로 문자열을 생성하고 라벨링하는 알고리즘입니다. 이 알고리즘을 통해 편리하게 많은 양의 OCR 학습/검증용 데이터셋을 생성할 수 있습니다.
- Source ROI 를 지정하여 원하는 위치에 문자열을 생성할 수 있습니다.
- 생성 문자의 Face/Edge 각각 색상 및 섞이는 비율을 선택할 수 있습니다.
- String or Character 기준으로 라벨링 방식을 선택할 수 있습니다.
- 생성 문자열의 개수, 길이 및 회전 각도 범위를 선택할 수 있습니다.
Source | |
---|---|
Result | |
![]() |
![]() |
Fig. RandomTextImageGeneratorDL 동작 수행 결과
2 API
EnableRandomFont(bool bRandomFont = false)
bRandomFont
: 무작위 폰트 사용 플래그
SetFontName(const Base::CFLString<wchar_t>& flsFontName = L"Arial")
flsFontName
: 폰트 이름
SetFontSize(float f32MinFontSize = 10.f, float f32MaxFontSize = 30.f)
f32MinFontSize
: 최소 폰트 크기f32MaxFontSize
: 최대 폰트 크기
SetCharacterType(ECharacterType eCharacterType = ECharacterType_Integer_Lowercase_Uppercase)
bFaceColor
: 문자 종류
SetFaceColorMode(EColorMode eColorMode = EColorMode_Fixed)
eColorMode
: 내부 색상을 입히는 방식
SetFaceColor(const Base::CMultiVar<double>& mvColor = Base::CMultiVar<double>(0.))
mvColor
: 내부 색상
SetFaceAlphaBlendRatio(double f64MinRatio = 0.3, double f64MaxRatio = 0.6)
f64MinRatio
: 내부 색상이 섞이는 최소 비율f64MaxRatio
: 내부 색상이 섞이는 최대 비율
SetEdgeColorMode(EColorMode eColorMode = EColorMode_Fixed)
eColorMode
: 경계 색상을 입히는 방식
SetEdgeColor(const Base::CMultiVar<double>& mvColor = Base::CMultiVar<double>(0.))
mvColor
: 경계 색상
SetEdgeAlphaBlendRatio(double f64MinRatio = 0.8, double f64MaxRatio = 1.0)
f64MinRatio
: 경계 색상이 섞이는 최소 비율f64MaxRatio
: 경계 색상이 섞이는 최대 비율
EnableLabelFigure(bool bLabelFigure = true)
bLabelFigure
: 라벨링 기능 사용 플래그
SetLabelFigureType(ELabelFigureType eLabelFigureType = ELabelFigureType_String)
eLabelFigureType
: 라벨링 방식
SetTextCount(int32_t i32MinTextCount = 0, int32_t i32MaxTextCount = 5)
i32MinTextCount
: 최소 문자열 개수i32MaxTextCount
: 최대 문자열 개수
SetCharacterCountPerText(int32_t i32MinCharacterCount = 1, int32_t i32MaxCharacterCount = 10)
i32MinCharacterCount
: 문자열 당 최소 문자 개수i32MaxCharacterCount
: 문자열 당 최대 문자 개수
SetRotationAngle(double f64MinAngle = -5.0, double f64MaxAngle = 5.0)
f64MinAngle
: 최소 회전 각도f64MaxAngle
: 최대 회전 각도
3 예제 코드:
CResult res;
CFLImage fliSourceImage;
CFLImage fliResultImage;
CRandomTextImageGeneratorDL randomTextImageGeneratorDL;
if(IsFail(res = fliSourceImage.Load(L"Source.flif")))
break;
randomTextImageGeneratorDL.SetSourceImage(fliSourceImage);
randomTextImageGeneratorDL.SetDestinationImage(fliResultImage);
randomTextImageGeneratorDL.SetFontSize(30.f, 70.f);
randomTextImageGeneratorDL.SetTextCount(3, 10);
randomTextImageGeneratorDL.SetRotationAngle(-30., 30.);
if(IsFail(res = randomTextImageGeneratorDL.Execute()))
break;
if(IsFail(res = fliResultImage.Save(L"Result.flif")))
break;