Skip to content

Commit

Permalink
sweated for about an hour before realising the build path was wrong. …
Browse files Browse the repository at this point in the history
…fixed
  • Loading branch information
elliotwoods committed Nov 30, 2011
1 parent e856890 commit 59efae5
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Package/Development Tests/ImageLoad.v4p
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE PATCH SYSTEM "http://vvvv.org/versions/vvvv45beta26.dtd" >
<PATCH nodename="C:\kimchiandchips\VVVV.Research\VVVV.Nodes.EmguCV\Development Tests\ImageLoad.v4p" filename="C:\kimchiandchips\VVVV.Research\VVVV.Nodes.EmguCV\Development Tests\ImageLoad.v4p" systemname="ImageLoad">
<PATCH nodename="C:\kimchiandchips\VVVV.Research\VVVV.Nodes.EmguCV\Package\Development Tests\ImageLoad.v4p" filename="C:\kimchiandchips\VVVV.Research\VVVV.Nodes.EmguCV\Development Tests\ImageLoad.v4p" systemname="ImageLoad">
<BOUNDS height="12630" left="8295" top="1710" type="Window" width="9000">
</BOUNDS>
<NODE componentmode="Hidden" id="5" nodename="Quad (DX9)" systemname="Quad (DX9)">
Expand Down Expand Up @@ -122,6 +122,6 @@
</LINK>
<LINK dstnodeid="25" dstpinname="Input" srcnodeid="23" srcpinname="Output">
</LINK>
<LINK srcnodeid="24" srcpinname="Texture Out" dstnodeid="5" dstpinname="Texture">
<LINK dstnodeid="5" dstpinname="Texture" srcnodeid="24" srcpinname="Texture Out">
</LINK>
</PATCH>
3 changes: 3 additions & 0 deletions VVVV.Nodes.KC.EmguCV.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>Package\Plugins\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="Emgu.CV" />
<Reference Include="Emgu.CV.UI" />
Expand Down
Binary file added VVVV.Nodes.OpenCV.zip
Binary file not shown.
13 changes: 8 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
## WARNING
the code has been quite rushed over the past 4 days
likely there's some bad code in here that i have to go back later to scoop out.
scooping hands welcome! :)

Introduction
============
https://github.com/elliotwoods/VVVV.Nodes.EmguCV
Expand Down Expand Up @@ -43,6 +38,13 @@ TODO: make notes for quick installation :)
Operating notes
===============

Known issues
------------
* Changing slice counts in image inputs/outputs will sometimes cause crashes. Fixing this is somewhat of a priority, and relates to things being properly disposed (which is also of general importance).
* Changing slice counts on processor nodes (generators, filters, destinations) doesn't result in input properties being updated for the instances.
* We don't handle stride (useful for non '4 byte' image types at non power of 2 resolutions)


Video playback
--------------
This isn't necessarilly the best route for video playback, but can also work quite nicely.
Expand All @@ -53,6 +55,7 @@ Notes for video playback:
* No audio, probably never will have (although other nodes which output CVImage type could give audio).
* Works with pretty much all the AVI's i threw at it (which isn't that many on this PC). Feedback welcome!


Types
-----
We are now using CVImageLink which is a polymorphic (accepts different formats of image), double threaded (handles threading, locking) and auto converting (e.g. for RGBA8 for GPU) image type.
Expand Down
4 changes: 2 additions & 2 deletions src/Image/CVImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public bool SetImage(CVImage source)
}

/// <summary>
/// Copy data from pointer. Presume we're already correctly initialised
/// Copy data from pointer. Presume we're initialised and data is of correct size
/// </summary>
/// <param name="source">Raw pixel data of correct size</param>
/// <param name="rawData">Raw pixel data of correct size</param>
public void SetPixels(IntPtr rawData)
{
if (rawData == IntPtr.Zero)
Expand Down
22 changes: 3 additions & 19 deletions src/Sources/ImageLoadNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ namespace VVVV.Nodes.EmguCV
public class ImageLoadInstance : IGeneratorInstance
{
string FLoadedImage = "";

private string FStatus = "";
public string Status
{
get
{
return FStatus;
}
}


public override bool NeedsThread()
{
return false;
Expand Down Expand Up @@ -48,11 +39,11 @@ private void LoadImage(string filename)
FOutput.Image.LoadFile(filename);
FLoadedImage = filename;
FOutput.Send();
FStatus = "OK";
Status = "OK";
}
catch
{
FStatus = "Image load failed";
Status = "Image load failed";
FLoadedImage = "";
}
}
Expand All @@ -70,9 +61,6 @@ public class ImageLoadNode : IGeneratorNode<ImageLoadInstance>
[Input("Reload", IsBang = true)]
ISpread<bool> FPinInReload;

[Output("Status")]
ISpread<string> FPinOutStatus;

[Import]
ILogger FLogger;
#endregion fields&pins
Expand All @@ -85,8 +73,6 @@ public ImageLoadNode()

protected override void Update(int InstanceCount)
{
FPinOutStatus.SliceCount = InstanceCount;

if (FPinInFilename.IsChanged)
for (int i = 0; i < InstanceCount; i++)
FProcessor[i].Filename = FPinInFilename[i];
Expand All @@ -95,8 +81,6 @@ protected override void Update(int InstanceCount)
{
if (FPinInReload[i])
FProcessor[i].Reload();

FPinOutStatus[i] = FProcessor[i].Status;
}
}
}
Expand Down
33 changes: 33 additions & 0 deletions src/User Interfaces/IGeneratorInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,39 @@ public void SetOutput(CVImageOutput output)
/// </summary>
protected virtual void Generate() { }

public string Status { get ; protected set; }

protected bool FEnabled;
public bool Enabled
{
get
{
return FEnabled;
}
set
{
if (FEnabled == value)
return;

FEnabled = value;
if (FEnabled)
Enable();
else
Disable();

}
}

/// <summary>
/// Override this function if you need to do something when FEnabled goes high.
/// </summary>
virtual protected void Enable() { }

/// <summary>
/// Override this function if you need to do something when FEnabled goes low.
/// </summary>
virtual protected void Disable() { }

virtual public void Dispose()
{

Expand Down
17 changes: 15 additions & 2 deletions src/User Interfaces/IGeneratorNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,32 @@ namespace VVVV.Nodes.EmguCV
{
public abstract class IGeneratorNode<T> : IPluginEvaluate, IDisposable where T : IGeneratorInstance, new()
{
[Input("Enabled")]
private ISpread<bool> FPinInEnabled;

[Output("Output", Order = -1)]
private ISpread<CVImageLink> FOutput;
private ISpread<CVImageLink> FPinOutOutput;

[Output("Status")]
private ISpread<string> FPinOutStatus;

protected ProcessGenerator<T> FProcessor;

public void Evaluate(int SpreadMax)
{
if (FProcessor == null)
FProcessor = new ProcessGenerator<T>(FOutput, SpreadMax);
FProcessor = new ProcessGenerator<T>(FPinOutOutput, SpreadMax);

FProcessor.CheckSliceCount(SpreadMax);

for (int i = 0; i < SpreadMax; i++)
FProcessor[i].Enabled = FPinInEnabled[i];

Update(SpreadMax);

FPinOutStatus.SliceCount = SpreadMax;
for (int i = 0; i < SpreadMax; i++)
FPinOutStatus[i] = FProcessor[i].Status;
}

protected abstract void Update(int InstanceCount);
Expand Down

0 comments on commit 59efae5

Please sign in to comment.