Permalink
Browse files

-Factory now loads as AutoEvaluate (temporary for testing)

-Parameters now use IDiffSpread and has sync IsChanged message.
-File uses IsChanged
-Add GrayScale/Threshold for testing
-Renamed Info 1 to Info
-Window Resizes the bitmap
  • Loading branch information...
1 parent 6edd8af commit 700473345152d3f686fd879105c21a5be345de2c @mrvux committed Oct 3, 2011
@@ -58,12 +58,9 @@ public class StreamProcessorFactory : AbstractFileFactory<IInternalPluginHost>
public StreamProcessorFactory(CompositionContainer parentContainer,IHDEHost hdeHost)
: this(parentContainer, ".dll")
{
- this.graphbuilder = new viGraphBuilder2<IStreamProcessor>(hdeHost);
-
- this.graphbuilder.RegisterPinType<InternalStream<DoubleStream>>();
+ this.graphbuilder = new viGraphBuilder2<IStreamProcessor>(hdeHost);
this.graphbuilder.RegisterPinType<InternalStream<ImageStream>>();
-
-
+
this.graphbuilder.NodeAdded += new NodeEventDelegate(graphbuilder_NodeAdded);
this.graphbuilder.NodeRemoved += new NodeEventDelegate(graphbuilder_NodeRemoved);
this.graphbuilder.LinkAdded += new LinkEventDelegate(graphbuilder_LinkAdded);
@@ -148,8 +145,7 @@ protected override bool CreateNode(INodeInfo nodeInfo, IInternalPluginHost plugi
var filter = (IStreamProcessor)Activator.CreateInstance((Type)nodeInfo.UserData);
var node = new StreamHostNode(pluginHost);
-
-
+
node.SetProcessor(filter);
pluginHost.Plugin = node;
@@ -197,9 +193,9 @@ protected void LoadNodeInfosFromFile(string filename, string sourcefilename, ref
nodeInfo.Factory = this;
nodeInfo.Type = NodeType.Plugin;
nodeInfo.UserData = t;
-
nodeInfo.CommitUpdate();
nodeInfo.UserData = t;
+ nodeInfo.AutoEvaluate = true;
nodeInfos.Add(nodeInfo);
}
@@ -13,27 +13,38 @@ public class Parameter<T> : IParameter
{
private IPluginHost host;
- private ISpread<T> internaldata;
+ private IDiffSpread<T> internaldata;
private List<T> cache;
private object m_lock = new object();
+ private bool haschanged = true;
+
internal Parameter(IPluginHost host, string name)
{
this.host = host;
InputAttribute attr = new InputAttribute(name);
- this.internaldata = PinFactory.CreateSpread<T>(host, attr);
+ this.internaldata = PinFactory.CreateDiffSpread<T>(host, attr);
this.CacheData();
}
+ public bool IsChanged
+ {
+ get { return this.haschanged; }
+ }
+
public List<T> Data
{
- get { return this.cache; }
+ get
+ {
+ this.haschanged = false;
+ return this.cache;
+ }
}
/// <summary>
@@ -42,9 +53,13 @@ public List<T> Data
/// </summary>
public void CacheData()
{
- lock (this.m_lock)
+ if (this.internaldata.IsChanged)
{
- this.cache = new List<T>(this.internaldata);
+ lock (this.m_lock)
+ {
+ this.cache = new List<T>(this.internaldata);
+ }
+ this.haschanged = true;
}
}
}
@@ -80,7 +80,6 @@
<Compile Include="DataTypes\Parameters\IParameter.cs" />
<Compile Include="DataTypes\Parameters\Parameter.cs" />
<Compile Include="DataTypes\Streams\BaseInputStream.cs" />
- <Compile Include="DataTypes\Streams\Data\IDoubleStream.cs" />
<Compile Include="DataTypes\Streams\Data\ImageStream.cs" />
<Compile Include="DataTypes\Streams\IBaseStream.cs">
<SubType>Code</SubType>
@@ -17,7 +17,6 @@ public class FileSourceTest1 : IStreamProcessor
private IStreamHost host;
private Parameter<string> path;
- private string oldpath = String.Empty;
private OutputStream<ImageStream> to;
@@ -34,7 +33,7 @@ public void Init(IStreamHost host)
public void Process()
{
- if (oldpath != this.path.Data[0])
+ if (this.path.IsChanged)
{
if (this.to.Data.Image != null)
{
@@ -43,14 +42,13 @@ public void Process()
try
{
- this.to.Data.Image = new Emgu.CV.Image<Gray, Byte>(this.path.Data[0]);
+ this.to.Data.Image = new Emgu.CV.Image<Bgr, Byte>(this.path.Data[0]);
}
catch
{
this.to.Data.Image = null;
}
}
- this.oldpath = this.path.Data[0];
}
#endregion
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using VVVV.CV.Lib.Interfaces;
+using VVVV.CV.Lib.Host;
+using VVVV.CV.Lib.DataTypes;
+using System.Diagnostics;
+using VVVV.CV.Lib.DataTypes.Streams.Data;
+using Emgu.CV.Structure;
+using Emgu.CV;
+
+namespace VVVV.CV.Nodes
+{
+ [StreamProcessorInfo("GrayScale")]
+ public class GrayScaleFilter : IStreamProcessor
+ {
+ private IStreamHost host;
+
+ private InputStream<ImageStream> image;
+
+ private OutputStream<ImageStream> outimg;
+
+ #region IStreamProcessor Members
+ public void Init(IStreamHost host)
+ {
+ this.host = host;
+ this.image = host.CreateInputStream<ImageStream>("Stream In");
+
+ this.outimg = host.CreateOutputStream<ImageStream>("Stream Out");
+ }
+
+ public void Process()
+ {
+ if (this.outimg.Data.IsValid)
+ {
+ this.outimg.Data.Image.Dispose();
+ }
+
+ if (this.image.IsValid)
+ {
+ IImage src = this.image.Data.Image;
+
+ Emgu.CV.Image<Gray,Byte> g = new Emgu.CV.Image<Gray,byte>(src.Size.Width,src.Size.Height);
+ Emgu.CV.CvInvoke.cvCvtColor(src.Ptr, g.Ptr, Emgu.CV.CvEnum.COLOR_CONVERSION.CV_BGR2GRAY);
+ this.outimg.Data.Image = g;
+ }
+ else
+ {
+ this.outimg.Data.Image = null;
+ }
+ }
+ #endregion
+
+
+ public void Dispose()
+ {
+ //Release any temp resource here
+ }
+
+ }
+}
@@ -10,41 +10,37 @@
namespace VVVV.CV.Nodes
{
- [StreamProcessorInfo("Info 1")]
+ [StreamProcessorInfo("Info")]
public class InfoTest1 : IStreamProcessor
{
private IStreamHost host;
private InputStream<ImageStream> image;
- private OutputData<int> width;
+ private OutputData<int> size;
#region IStreamProcessor Members
public void Init(IStreamHost host)
{
this.host = host;
this.image = host.CreateInputStream<ImageStream>("Stream In");
- this.width = host.CreateOutput<int>("Output 1");
+ this.size = host.CreateOutput<int>("Output 1");
}
public void Process()
{
if (this.image.IsValid)
{
- // Emgu.CV.Image<Emgu.CV.Structure.Bgr,Byte> img ;//= new Emgu.CV.Image<Emgu.CV.Structure.Bgr,byte>(
-
- //img.
- //this.image.Data.Image
- this.width.Data.Clear();
- this.width.Data.Add(this.image.Data.Image.Size.Width);
- this.width.Data.Add(this.image.Data.Image.Size.Height);
+ this.size.Data.Clear();
+ this.size.Data.Add(this.image.Data.Image.Size.Width);
+ this.size.Data.Add(this.image.Data.Image.Size.Height);
}
else
{
- this.width.Data.Clear();
- this.width.Data.Add(0);
- this.width.Data.Add(0);
+ this.size.Data.Clear();
+ this.size.Data.Add(0);
+ this.size.Data.Add(0);
}
}
@@ -29,16 +29,14 @@ public void Init(IStreamHost host)
this.frm = new Form();
this.frm.Show();
- frm.Paint += new PaintEventHandler(frm_Paint);
-
-
+ frm.Paint += new PaintEventHandler(frm_Paint);
}
void frm_Paint(object sender, PaintEventArgs e)
{
if (b != null)
{
- e.Graphics.DrawImage(b, 0, 0);
+ e.Graphics.DrawImage(b, 0, 0, this.frm.Width, this.frm.Height);
}
}
@@ -0,0 +1,79 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using VVVV.CV.Lib.Interfaces;
+using VVVV.CV.Lib.Host;
+using VVVV.CV.Lib.DataTypes;
+using System.Diagnostics;
+using VVVV.CV.Lib.DataTypes.Streams.Data;
+using Emgu.CV.Structure;
+using Emgu.CV;
+
+namespace VVVV.CV.Nodes
+{
+ [StreamProcessorInfo("Threshold")]
+ public class ThresholdFilter : IStreamProcessor
+ {
+ private IStreamHost host;
+
+ private InputStream<ImageStream> image;
+ private Parameter<double> thr;
+ private Parameter<double> max;
+ private Parameter<Emgu.CV.CvEnum.THRESH> thresholdtype;
+
+ private OutputStream<ImageStream> outimg;
+
+ #region IStreamProcessor Members
+ public void Init(IStreamHost host)
+ {
+ this.host = host;
+ this.image = host.CreateInputStream<ImageStream>("Stream In");
+ this.thr = host.CreateParameter<double>("Threshold");
+ this.max = host.CreateParameter<double>("Max Value");
+ this.thresholdtype = host.CreateParameter<Emgu.CV.CvEnum.THRESH>("Threshold Type");
+
+ this.outimg = host.CreateOutputStream<ImageStream>("Stream Out");
+ }
+
+ public void Process()
+ {
+ if (this.image.IsValid)
+ {
+ IImage src = this.image.Data.Image;
+ IImage output = null;
+ if (this.outimg.Data.IsValid)
+ {
+ output = this.outimg.Data.Image;
+ if (output.Size != src.Size)
+ {
+ output.Dispose();
+ output = null;
+ }
+ }
+
+ if (output == null)
+ {
+ output = new Emgu.CV.Image<Gray, byte>(src.Size.Width, src.Size.Height);
+
+ }
+
+ Emgu.CV.CvInvoke.cvThreshold(src.Ptr, output.Ptr,this.thr.Data[0], this.max.Data[0],this.thresholdtype.Data[0]);
+
+ this.outimg.Data.Image = output;
+ }
+ else
+ {
+ this.outimg.Data.Image = null;
+ }
+ }
+ #endregion
+
+
+ public void Dispose()
+ {
+ //Release any temp resource here
+ }
+
+ }
+}
@@ -63,11 +63,11 @@
</ItemGroup>
<ItemGroup>
<Compile Include="FileTest1.cs" />
+ <Compile Include="GrayScaleFilter.cs" />
<Compile Include="InfoTest1.cs" />
- <Compile Include="SinkTest1.cs" />
- <Compile Include="SourceTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestWindow1.cs" />
+ <Compile Include="ThresholdFilter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VVVV.CV.Factories\VVVV.CV.Factories.csproj">
Oops, something went wrong.

0 comments on commit 7004733

Please sign in to comment.