RoiCfg.SaveImages introduced, Program.ImagesDir introduced - directory cleaned or created on program startup.
This commit is contained in:
parent
44735260ce
commit
fc26b95bdb
@ -61,6 +61,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
{
|
||||
detected = false;
|
||||
}
|
||||
///
|
||||
public void SetRoi(int x, int y, int wid, int hgh)
|
||||
{
|
||||
RoiX.Val = x;
|
||||
@ -128,8 +129,9 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
if (args.Command == CfgChangeCmd.CfgChange)
|
||||
{
|
||||
RoiCfg.RoiParams = tmpcfg.RoiParams;
|
||||
RoiCfg.UseTestImages = tmpcfg.UseTestImages;
|
||||
RoiCfg.DetectionImagesCount = tmpcfg.DetectionImagesCount;
|
||||
RoiCfg.LoadImages = tmpcfg.LoadImages;
|
||||
RoiCfg.SaveImages = tmpcfg.SaveImages;
|
||||
RoiCfg.DetectionPeriod1 = tmpcfg.DetectionPeriod1;
|
||||
RoiCfg.DetectionPeriod2 = tmpcfg.DetectionPeriod2;
|
||||
}
|
||||
@ -153,7 +155,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
if (NetCamera != null && NetCamera.Telnet != null)
|
||||
{
|
||||
Telnet = NetCamera.Telnet;
|
||||
detectedImageName = string.Format("c:\\TBF\\TftpRoot\\{0}-det-{1}.jpg", RoiCfg.Name, StateMachine.Time);
|
||||
detectedImageName = string.Format("{0}{1}-det-{2}.jpg", Program.ImagesDir, RoiCfg.Name, StateMachine.Time);
|
||||
return new RoiDetectionOp(this, RoiX, RoiY, RoiWid, RoiHgh);
|
||||
}
|
||||
else
|
||||
|
||||
@ -19,7 +19,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
public int DetectionImagesCount;
|
||||
public int DetectionPeriod1;
|
||||
public int DetectionPeriod2;
|
||||
public bool UseTestImages;
|
||||
public bool LoadImages;
|
||||
public bool SaveImages;
|
||||
|
||||
/// <summary> Procedure parameters </summary>
|
||||
[XmlIgnore]
|
||||
@ -52,9 +53,10 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("{0} ({1}), N={2}, P1={3}, P2={4}, Prms={5} {6}",
|
||||
Name, ParentName, DetectionImagesCount, DetectionPeriod1, DetectionPeriod2,
|
||||
RoiParams, UseTestImages ? "TEST" : "");
|
||||
return string.Format("{0} ({1}), N={2}{3}, P1={4}, P2={5}, Prms={6}",
|
||||
Name, ParentName, DetectionImagesCount,
|
||||
LoadImages ? " load" : (SaveImages ? " save" : ""),
|
||||
DetectionPeriod1, DetectionPeriod2, RoiParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
||||
previousRoiComboBox.Text = string.IsNullOrEmpty(config.PreviousRoi) ? "---" : config.PreviousRoi;
|
||||
argsTextBox.Text = config.RoiParams;
|
||||
useTestImagesCheckBox.Checked = config.UseTestImages;
|
||||
loadImagesCheckBox.Checked = config.LoadImages;
|
||||
saveImagesCheckBox.Checked = config.SaveImages;
|
||||
imagesCountTextBox.Text = config.DetectionImagesCount.ToString();
|
||||
period1TextBox.Text = config.DetectionPeriod1.ToString();
|
||||
period2TextBox.Text = config.DetectionPeriod2.ToString();
|
||||
@ -81,7 +82,8 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
parentNameComboBox.Enabled = true;
|
||||
previousRoiComboBox.Enabled = true;
|
||||
argsTextBox.Enabled = true;
|
||||
useTestImagesCheckBox.Enabled = true;
|
||||
loadImagesCheckBox.Enabled = true;
|
||||
saveImagesCheckBox.Enabled = true;
|
||||
imagesCountTextBox.Enabled = true;
|
||||
period1TextBox.Enabled = true;
|
||||
period2TextBox.Enabled = true;
|
||||
@ -130,6 +132,12 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
message += Environment.NewLine + "When Period2 > Period1, 'Images count' should be even";
|
||||
}
|
||||
|
||||
if (loadImagesCheckBox.Checked && saveImagesCheckBox.Checked)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Images cannot be Loaded and Saved at the same time";
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
@ -165,9 +173,15 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
if (config.UseTestImages != useTestImagesCheckBox.Checked)
|
||||
if (config.LoadImages != loadImagesCheckBox.Checked)
|
||||
{
|
||||
config.UseTestImages = useTestImagesCheckBox.Checked;
|
||||
config.LoadImages = loadImagesCheckBox.Checked;
|
||||
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
if (config.SaveImages != saveImagesCheckBox.Checked)
|
||||
{
|
||||
config.SaveImages = saveImagesCheckBox.Checked;
|
||||
flags |= (CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
}
|
||||
|
||||
|
||||
@ -46,12 +46,13 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.imagesCountTextBox = new System.Windows.Forms.TextBox();
|
||||
this.imagesCountLabel = new System.Windows.Forms.Label();
|
||||
this.useTestImagesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.loadImagesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.period1TextBox = new System.Windows.Forms.TextBox();
|
||||
this.period1Label = new System.Windows.Forms.Label();
|
||||
this.period2TextBox = new System.Windows.Forms.TextBox();
|
||||
this.period2Label = new System.Windows.Forms.Label();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.saveImagesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -61,7 +62,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.argsTextBox.Location = new System.Drawing.Point(92, 19);
|
||||
this.argsTextBox.Name = "argsTextBox";
|
||||
this.argsTextBox.Size = new System.Drawing.Size(361, 20);
|
||||
this.argsTextBox.TabIndex = 7;
|
||||
this.argsTextBox.TabIndex = 1;
|
||||
//
|
||||
// argsLabel
|
||||
//
|
||||
@ -69,7 +70,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.argsLabel.Location = new System.Drawing.Point(6, 22);
|
||||
this.argsLabel.Name = "argsLabel";
|
||||
this.argsLabel.Size = new System.Drawing.Size(57, 13);
|
||||
this.argsLabel.TabIndex = 6;
|
||||
this.argsLabel.TabIndex = 0;
|
||||
this.argsLabel.Text = "Arguments";
|
||||
//
|
||||
// parentNameLabel
|
||||
@ -78,7 +79,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.parentNameLabel.Location = new System.Drawing.Point(13, 60);
|
||||
this.parentNameLabel.Name = "parentNameLabel";
|
||||
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
|
||||
this.parentNameLabel.TabIndex = 2;
|
||||
this.parentNameLabel.TabIndex = 3;
|
||||
this.parentNameLabel.Text = "Parent Name";
|
||||
//
|
||||
// nameTextBox
|
||||
@ -87,7 +88,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.nameTextBox.Location = new System.Drawing.Point(99, 34);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(174, 20);
|
||||
this.nameTextBox.TabIndex = 1;
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
@ -95,7 +96,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.nameLabel.Location = new System.Drawing.Point(13, 37);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 0;
|
||||
this.nameLabel.TabIndex = 1;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
@ -114,7 +115,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.parentNameComboBox.Location = new System.Drawing.Point(99, 57);
|
||||
this.parentNameComboBox.Name = "parentNameComboBox";
|
||||
this.parentNameComboBox.Size = new System.Drawing.Size(174, 21);
|
||||
this.parentNameComboBox.TabIndex = 3;
|
||||
this.parentNameComboBox.TabIndex = 4;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@ -140,7 +141,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.previousRoiComboBox.Location = new System.Drawing.Point(99, 81);
|
||||
this.previousRoiComboBox.Name = "previousRoiComboBox";
|
||||
this.previousRoiComboBox.Size = new System.Drawing.Size(174, 21);
|
||||
this.previousRoiComboBox.TabIndex = 5;
|
||||
this.previousRoiComboBox.TabIndex = 6;
|
||||
//
|
||||
// previousRoiLabel
|
||||
//
|
||||
@ -148,7 +149,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.previousRoiLabel.Location = new System.Drawing.Point(13, 84);
|
||||
this.previousRoiLabel.Name = "previousRoiLabel";
|
||||
this.previousRoiLabel.Size = new System.Drawing.Size(68, 13);
|
||||
this.previousRoiLabel.TabIndex = 4;
|
||||
this.previousRoiLabel.TabIndex = 5;
|
||||
this.previousRoiLabel.Text = "Previous RoI";
|
||||
//
|
||||
// helpLabel1
|
||||
@ -157,7 +158,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.helpLabel1.Location = new System.Drawing.Point(91, 44);
|
||||
this.helpLabel1.Name = "helpLabel1";
|
||||
this.helpLabel1.Size = new System.Drawing.Size(379, 13);
|
||||
this.helpLabel1.TabIndex = 8;
|
||||
this.helpLabel1.TabIndex = 2;
|
||||
this.helpLabel1.Text = "roiWid roiHgh cx cy innerR outerR R3 ang1 ang2 fullAngle teethCount ..." +
|
||||
"";
|
||||
//
|
||||
@ -167,7 +168,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.label2.Location = new System.Drawing.Point(90, 62);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(350, 13);
|
||||
this.label2.TabIndex = 9;
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "... angSpeed( - ccw +cw) initSpeed minMvmt maxFwdMvmt bkgndCorr";
|
||||
//
|
||||
// imagesCountTextBox
|
||||
@ -176,7 +177,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.imagesCountTextBox.Location = new System.Drawing.Point(92, 84);
|
||||
this.imagesCountTextBox.Name = "imagesCountTextBox";
|
||||
this.imagesCountTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.imagesCountTextBox.TabIndex = 19;
|
||||
this.imagesCountTextBox.TabIndex = 5;
|
||||
//
|
||||
// imagesCountLabel
|
||||
//
|
||||
@ -184,19 +185,19 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.imagesCountLabel.Location = new System.Drawing.Point(6, 87);
|
||||
this.imagesCountLabel.Name = "imagesCountLabel";
|
||||
this.imagesCountLabel.Size = new System.Drawing.Size(71, 13);
|
||||
this.imagesCountLabel.TabIndex = 18;
|
||||
this.imagesCountLabel.TabIndex = 4;
|
||||
this.imagesCountLabel.Text = "Images count";
|
||||
//
|
||||
// useTestImagesCheckBox
|
||||
// loadImagesCheckBox
|
||||
//
|
||||
this.useTestImagesCheckBox.AutoSize = true;
|
||||
this.useTestImagesCheckBox.Enabled = false;
|
||||
this.useTestImagesCheckBox.Location = new System.Drawing.Point(183, 87);
|
||||
this.useTestImagesCheckBox.Name = "useTestImagesCheckBox";
|
||||
this.useTestImagesCheckBox.Size = new System.Drawing.Size(101, 17);
|
||||
this.useTestImagesCheckBox.TabIndex = 17;
|
||||
this.useTestImagesCheckBox.Text = "Use test images";
|
||||
this.useTestImagesCheckBox.UseVisualStyleBackColor = true;
|
||||
this.loadImagesCheckBox.AutoSize = true;
|
||||
this.loadImagesCheckBox.Enabled = false;
|
||||
this.loadImagesCheckBox.Location = new System.Drawing.Point(175, 87);
|
||||
this.loadImagesCheckBox.Name = "loadImagesCheckBox";
|
||||
this.loadImagesCheckBox.Size = new System.Drawing.Size(112, 17);
|
||||
this.loadImagesCheckBox.TabIndex = 6;
|
||||
this.loadImagesCheckBox.Text = "Load images (test)";
|
||||
this.loadImagesCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// period1TextBox
|
||||
//
|
||||
@ -204,7 +205,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.period1TextBox.Location = new System.Drawing.Point(92, 107);
|
||||
this.period1TextBox.Name = "period1TextBox";
|
||||
this.period1TextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.period1TextBox.TabIndex = 21;
|
||||
this.period1TextBox.TabIndex = 9;
|
||||
//
|
||||
// period1Label
|
||||
//
|
||||
@ -212,7 +213,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.period1Label.Location = new System.Drawing.Point(6, 110);
|
||||
this.period1Label.Name = "period1Label";
|
||||
this.period1Label.Size = new System.Drawing.Size(46, 13);
|
||||
this.period1Label.TabIndex = 20;
|
||||
this.period1Label.TabIndex = 8;
|
||||
this.period1Label.Text = "Period 1";
|
||||
//
|
||||
// period2TextBox
|
||||
@ -221,7 +222,7 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.period2TextBox.Location = new System.Drawing.Point(92, 130);
|
||||
this.period2TextBox.Name = "period2TextBox";
|
||||
this.period2TextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.period2TextBox.TabIndex = 23;
|
||||
this.period2TextBox.TabIndex = 11;
|
||||
//
|
||||
// period2Label
|
||||
//
|
||||
@ -229,11 +230,12 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.period2Label.Location = new System.Drawing.Point(6, 133);
|
||||
this.period2Label.Name = "period2Label";
|
||||
this.period2Label.Size = new System.Drawing.Size(46, 13);
|
||||
this.period2Label.TabIndex = 22;
|
||||
this.period2Label.TabIndex = 10;
|
||||
this.period2Label.Text = "Period 2";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.saveImagesCheckBox);
|
||||
this.groupBox1.Controls.Add(this.argsTextBox);
|
||||
this.groupBox1.Controls.Add(this.period2TextBox);
|
||||
this.groupBox1.Controls.Add(this.argsLabel);
|
||||
@ -242,16 +244,27 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
this.groupBox1.Controls.Add(this.period1TextBox);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.period1Label);
|
||||
this.groupBox1.Controls.Add(this.useTestImagesCheckBox);
|
||||
this.groupBox1.Controls.Add(this.loadImagesCheckBox);
|
||||
this.groupBox1.Controls.Add(this.imagesCountTextBox);
|
||||
this.groupBox1.Controls.Add(this.imagesCountLabel);
|
||||
this.groupBox1.Location = new System.Drawing.Point(7, 110);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(477, 169);
|
||||
this.groupBox1.TabIndex = 24;
|
||||
this.groupBox1.TabIndex = 7;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "ROI Detection";
|
||||
//
|
||||
// saveImagesCheckBox
|
||||
//
|
||||
this.saveImagesCheckBox.AutoSize = true;
|
||||
this.saveImagesCheckBox.Enabled = false;
|
||||
this.saveImagesCheckBox.Location = new System.Drawing.Point(301, 87);
|
||||
this.saveImagesCheckBox.Name = "saveImagesCheckBox";
|
||||
this.saveImagesCheckBox.Size = new System.Drawing.Size(132, 17);
|
||||
this.saveImagesCheckBox.TabIndex = 7;
|
||||
this.saveImagesCheckBox.Text = "Save images (analyze)";
|
||||
this.saveImagesCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// RoiCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@ -293,11 +306,12 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TextBox imagesCountTextBox;
|
||||
private System.Windows.Forms.Label imagesCountLabel;
|
||||
private System.Windows.Forms.CheckBox useTestImagesCheckBox;
|
||||
private System.Windows.Forms.CheckBox loadImagesCheckBox;
|
||||
private System.Windows.Forms.TextBox period1TextBox;
|
||||
private System.Windows.Forms.Label period1Label;
|
||||
private System.Windows.Forms.TextBox period2TextBox;
|
||||
private System.Windows.Forms.Label period2Label;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.CheckBox saveImagesCheckBox;
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,9 +102,10 @@ namespace TBF.BenchControl.Network.Camera.Roi
|
||||
previous.RoiWid.Val, previous.RoiHgh.Val);
|
||||
previous = previous.PreviousRoi;
|
||||
}
|
||||
command = string.Format("clp/RoiDetection{0}{1}{2}{3} {4}",
|
||||
command = string.Format("clp/RoiDetection{0}{1}{2}{3}{4} {5}",
|
||||
masks,
|
||||
string.Format(roiCfg.UseTestImages ? " -l {0}" : " -n {0}", roiCfg.DetectionImagesCount),
|
||||
string.Format(roiCfg.LoadImages ? " -l {0}" : " -n {0}", roiCfg.DetectionImagesCount),
|
||||
roiCfg.SaveImages ? " -s" : "",
|
||||
string.Format(" -p1 {0}", roiCfg.DetectionPeriod1),
|
||||
string.Format(" -p2 {0}", roiCfg.DetectionPeriod2),
|
||||
roiCfg.RoiParams);
|
||||
|
||||
@ -192,7 +192,7 @@ namespace TBF.BenchControl.TestMethods.RoiDetection
|
||||
|
||||
if (e.Contains(Event.Retry))
|
||||
{
|
||||
for (int i = 0; i < Math.Min(sensPath.RegisterReaders.Length, display.SelectedImages.Length); i++)
|
||||
for (int i = 0; i < display.SelectedImages.Length; i++)
|
||||
{
|
||||
GenericDevices.IRoi roi = sensPath.RegisterReaders[i] as GenericDevices.IRoi;
|
||||
if (roi != null && display.SelectedImages[i])
|
||||
|
||||
@ -15,7 +15,8 @@ namespace TBF
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public const string HomeDir = "C:\\Tbf\\"; /// Contains subdirectories Results, Logs, Images, ...
|
||||
public const string HomeDir = "C:\\Tbf\\"; /// Contains subdirectories Results, Logs, Images, ...
|
||||
public const string ImagesDir = "C:\\Tbf\\Images\\";
|
||||
|
||||
/// log4net
|
||||
static ILog log;
|
||||
@ -92,6 +93,10 @@ namespace TBF
|
||||
{
|
||||
Environment.CurrentDirectory = locAppDataDir;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(ImagesDir)) Directory.CreateDirectory(ImagesDir);
|
||||
IEnumerable<string> files = Directory.EnumerateFiles(ImagesDir);
|
||||
foreach (var file in files) File.Delete(file);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user