커스텀 모듈 코드가 어디가 문제인지 전혀 감이 안잡힙니다...... image. saver (경로)를......
페이지 정보
본문
[Category("Action")]
[DisplayName("이미지 찾을 범위")]
[Description("찾아라 이미지를 그리고 발견되길.")]
[Browsable(true)]
[ComVisible(true)]
[TypeConverter(typeof(RectangleConverter))]
public Rectangle Search { get; set; }
public override bool? Execute(NGM.Interface.IMainView mainView, NGM.Interface.IPlayer player)
{
Rectangle rect;
bool isSame;
string[] imageFullNames = { ImageFullName1};
string[] trueIDs = { Image1TrueID};
int index = 0;
foreach (string imageFullName in imageFullNames)
{
if (string.IsNullOrEmpty(imageFullName))
{
index++;
continue;
}
string fullName = Path.Combine((mainView.OptionConfig as NGM.Models.Configuration.OptionConfigModel)
.ImageDirectory, imageFullName);
if (!File.Exists(fullName))
{
if (mainView != null && mainView.ShowConditionOutput)
player.WriteOutput($"{mainView.ResxMessage.GetString("FileNotFound")}{Environment.NewLine}{mainView.ResxCaption.GetString("FilePath")}: {imageFullName}");
index++;
continue;
}
NGM.Models.ImageModel imageModel;
using (Stream file = File.Open(fullName, FileMode.Open, FileAccess.Read, FileShare.Read))
{
BinaryFormatter bf = new BinaryFormatter();
imageModel = (NGM.Models.ImageModel)bf.Deserialize(file);
}
// sourceImage = (Image)imageModel.Image;
// sourceImage = NGM.Utility.ImageManager.OpenCV.Binary(sourceImage, true, imageModel.BinaryThreshold);
// sourceImage = NGM.Utility.ImageManager.OpenCV.BrightnessContrast(sourceImage, imageModel.Brightness, imageModel.Contrast);
Image sourceImage = null;
Image targetImage = null;
//불러온 이미지는 투명픽셀 적용(반전)
sourceImage = NGM.Utility.ImageManager.OpenCV.TransparentPixel(imageModel.Image, imageModel.TransparentColors, imageModel.TransparentValue, imageModel.TransparentRange,true);
//찾아야될 영역 안에 있는 이미지는 투명픽셀적용 명도 및 대비적용 이진화 적용
if (player.MainHandle == IntPtr.Zero)
targetImage = NGM.Utility.ScreenCaptureManager.ScreenShot.GetActiveImage(Search , player);
else
targetImage = NGM.Utility.ScreenCaptureManager.ScreenShot.GetInactiveImage(player, Rectangle.Empty, Rectangle.Empty, Rectangle.Empty, false);
targetImage = NGM.Utility.ImageManager.OpenCV. TransparentPixel(targetImage, imageModel.TransparentColors, imageModel.TransparentValue, imageModel.TransparentRange, true);
targetImage = NGM.Utility.ImageManager.OpenCV.Binary(targetImage, false, imageModel.BinaryThreshold);
targetImage = NGM.Utility.ImageManager.OpenCV.BrightnessContrast(targetImage, imageModel.Brightness, imageModel.Contrast);
//비교하기 공차 10
rect = NGM.Utility.ImageManager.ImageCondition.IsSearch(sourceImage, targetImage, 10, false) ;
isSame = !rect.IsEmpty;
if (isSame)
{
base.TrueID = trueIDs[index];
this.SearchRectangle = rect;
this.SearchPoint = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
return true;
}
#region 리소스 해제
if (sourceImage != null)
{
sourceImage.Dispose();
sourceImage = null;
}
if (targetImage != null)
{
targetImage.Dispose();
targetImage = null;
}
if (imageModel != null)
{
if (imageModel.Image != null)
{
imageModel.Image.Dispose();
imageModel.Image = null;
}
imageModel = null;
}
#endregion
index++;
}
base.FalseID = ImageAllFalseID;
return false;
}
}
어디부분이 문제인지 모르겠습니다
[ComVisible(true)]
[TypeConverter(typeof(RectangleConverter))]
이걸 넣너도 빌드가 되고 안넣어도 빌드가 됩니다 이미지 영역을 지정하기위해 new Rectangle() 이걸 타겟 이미지에 있는 Search 이부분에 넣으면 저 앞에 있는 건 어디서 값을 가져오는지 항목을 만들어야 하는데 항목을 만들 속성을 만들면 저게 어떻게 들어가게 해야할지 몰라서 좌표를 받아오게 만들었는데 어느부분을 잘못했는지 도저히 봐도 모르겠네요 ㅠㅠ
참조를 보면서 하고 있는데 정말 모르겠습니다 ㅠㅠ
- 이전글vmware 커스텀모듈을 사서 진행중인데요, vmx파일을 선택하래서 선택했는데, 실행중인vmx파일만 선택가능하다는데 이게 무슨말인지 ... 20.05.16
- 다음글vm 에디터 질문있습니다. 20.05.16