Discussion:
How to use a .NET DLL that includes Object with Generic parameters
(too old to reply)
Tim C.
2008-08-05 15:10:08 UTC
Permalink
Is there a way to gain access to generic paramaters inside a .NET DLL.
 
I was wondering is the "To More Specific" function would help here?
 
Thanks In Advance
Tim C.
Tim C.
2008-08-05 15:10:11 UTC
Permalink
More Info... from another board, reason why I asked the question here...
 
----------------------------------It seems that Labview do not support Object with Generic parameters (which is a feature of .NET 2.0). The Image<TColor, TDepth> class requires two generic parameters and therefore do not show up in Labview.A work around might be, create you own dll and have a class ImageGrayByte that inherit Image<Gray, byte> with the constuctor that accept a file path. For example:

public class ImageGrayByte : Image<Gray, byte>{ public ImageGrayByte(string path) : base(path) {};}
compiles the above code and use it in Labview, you might be able to create an image object.
 
--------------------------------
 
Thanks
Tim C.
smercurio_fc
2008-08-05 16:40:07 UTC
Permalink
Is this a private "Image" class? I ask because the System.Drawing.Image class is an abstract class and has no public constructors that I'm aware of.
Tim C.
2008-08-05 18:10:07 UTC
Permalink
Still waiting on an answer to your question....
 
Does this help?
 
This is an open source library called OpenCV
---------------------------------
 
<a target="_blank" name="decl_cvLoadImage">cvLoadImage</a>

Loads an image from file/* 8 bit, color or gray - deprecated, use CV_LOAD_IMAGE_ANYCOLOR */
#define CV_LOAD_IMAGE_UNCHANGED -1
/* 8 bit, gray */
#define CV_LOAD_IMAGE_GRAYSCALE 0
/* 8 bit unless combined with CV_LOAD_IMAGE_ANYDEPTH, color */
#define CV_LOAD_IMAGE_COLOR 1
/* any depth, if specified on its own gray */
#define CV_LOAD_IMAGE_ANYDEPTH 2
/* by itself equivalent to CV_LOAD_IMAGE_UNCHANGED
but can be modified with CV_LOAD_IMAGE_ANYDEPTH */
#define CV_LOAD_IMAGE_ANYCOLOR 4

IplImage* cvLoadImage( const char* filename, int flags=CV_LOAD_IMAGE_COLOR );


filename
Name of file to be loaded.
flags
Specifies colorness and depth of the loaded image:The colorness specifies whether the loaded image is to be converted to 3 channels (CV_LOAD_IMAGE_COLOR), 1 channel (CV_LOAD_IMAGE_GRAYSCALE), or left as it was in the input file (CV_LOAD_IMAGE_ANYCOLOR).Depth specifies whether the loaded image is to be converted to 8 bits per pixel per color channel as was customary in previous versions of OpenCV or left as they were in the input file. If CV_LOAD_IMAGE_ANYDEPTH is passed the pixel format can be 8 bit unsigned, 16 bit unsigned, 32 bit signed or 32 bit floating point.If conflicting flags are passed the flag with the smaller numerical value wins. That is if CV_LOAD_IMAGE_COLOR | CV_LOAD_IMAGE_ANYCOLOR is passed the image is loaded with 3 channels. CV_LOAD_IMAGE_ANYCOLOR is equivalent to specifying CV_LOAD_IMAGE_UNCHANGED. However, CV_LOAD_IMAGE_ANYCOLOR has the advantage that it can be combined with CV_LOAD_IMAGE_ANYDEPTH. So CV_LOAD_IMAGE_UNCHANGED should not be used any longer.If you want to load the image as truthfully as possible pass CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR.
The function cvLoadImage loads an image from the specified file and returns the pointer to the loaded image. Currently the following file formats are supported:

- Windows bitmaps - BMP, DIB;
- JPEG files - JPEG, JPG, JPE;
- Portable Network Graphics - PNG;
- Portable image format - PBM, PGM, PPM;
- Sun rasters - SR, RAS;
- TIFF files - TIFF, TIF;
- OpenEXR HDR images - EXR;
- JPEG 2000 images - jp2.

------------------------------------------------
How do I get a path converted to a .NET Refnum?
&nbsp;
&nbsp;

&nbsp;
&nbsp;
smercurio_fc
2008-08-05 18:10:08 UTC
Permalink
That function has nothing to do with .NET - it's a C function. I don't understand where .NET fits into this.
Tim C.
2008-08-05 18:40:07 UTC
Permalink
A group put together a .NET Wrapper for the OpenCV functions.&nbsp; In the process it is my understanding that some of the properties used were generic.&nbsp; It is these generic properties that I am trying to get access to.....
&nbsp;
Best Regards
Tim C.
Tim C.
2008-08-05 18:40:08 UTC
Permalink
Here is th elink to teh folks that made the wrapper:
&nbsp;
<a href="http://www.emgu.com/wiki/index.php/Main_Page" target="_blank">http://www.emgu.com/wiki/index.php/Main_Page</a>
&nbsp;
smercurio_fc
2008-08-05 19:10:19 UTC
Permalink
OK. I see what that is now. My understanding is that the LabVIEW &lt;-&gt; .NET interface does not handle generics. Thus, in order to access a .NET class that uses generics you need to write a wrapper class. There was some discussion a while back about this being included in a future version of LabVIEW, but so far I haven't seen it. I could be wrong, though, since I haven't really tracked the issue of generics and LabVIEW for quite some time.Since that .NET class is just a wrapper around the OpenCV library you could just use the library directly using the Call Library Function node. It's not as nice as .NET, though.
Tim C.
2008-08-05 19:10:20 UTC
Permalink
Using theCall Library was going to be my next question....
&nbsp;
Back to the .NET wrappers....&nbsp; have you ever had a .NET Constructor working then saved and exited the app the upon reopening it the public
constructors were no longer available?&nbsp;
&nbsp;
This has happened a couple times with different .NET Wrappers.&nbsp; If so what did you have to do to get things working again?
&nbsp;
I have had some luck just basically fiddling but have never been able to nail a good solution.
&nbsp;
Thanks
Tim C.
smercurio_fc
2008-08-05 19:40:08 UTC
Permalink
Using theCall Library was going to be my next question....
Which is?
Back to the .NET wrappers....&nbsp; have you ever had a .NET Constructor working then saved and exited the app the upon reopening it the public
constructors were no longer available?&nbsp;
&nbsp;
This has happened a couple times with different .NET Wrappers.&nbsp; If so what did you have to do to get things working again?
&nbsp;
I have had some luck just basically fiddling but have never been able to nail a good solution.The only thing I can think of is that the .NET runtime is unable to find a dependent assembly. If your .NET assembly references another .NET assembly then the .NET runtime needs to be able to find it. If it can't find it, then the assembly won't work. The best way to deal with this is the have the dependent assemblies in the same folder as the wrapper assembly. You can take a look at the article <a href="http://digital.ni.com/public.nsf/allkb/C4EA5ABBEB67AF7C862573F3004D4421?OpenDocument" target="_blank">How LabVIEW Locates . NET Assemblies</a> for more information. Is there a way to have a path converted to a .NET refnum?I don't really understand what this means. There is no "refnum" class.
Tim C.
2008-08-05 19:40:10 UTC
Permalink
The .NET wrapper has an input called "Image"&nbsp; This input wants a .NET Refnum.&nbsp; But looking at the library itself it appears
to need path to the image file. So I was going to see if I could convert a path to a .NET Refnum and wire it to the image input.
smercurio_fc
2008-08-05 20:10:07 UTC
Permalink
The .NET wrapper has an input called "Image"&nbsp; This input wants a .NET Refnum.&nbsp; But looking at the library itself it appearsto need path to the image file. So I was going to see if I could convert a path to a .NET Refnum and wire it to the image input.The method actually needs a .NET class, so you have to instantiate a class or call a method that returns the appropriate class. Can you provide a link to the online page to the method (or at least the namespace-&gt;class-&gt;method) that you're referring to? I am not familiar with this library.
Tim C.
2008-08-05 20:40:10 UTC
Permalink
<a href="http://www.emgu.com/wiki/Help/Index.html" target="_blank">http://www.emgu.com/wiki/Help/Index.html</a>
&nbsp;
Emgu.CV&nbsp; -&gt; Image &lt;TColor, TDepth&gt;(String)&nbsp; appears to be the required hook to get an image...
&nbsp;
But none of the image parameters are public.
&nbsp;
Does this mean the Call Library Node is an easier approach?&nbsp;&nbsp;&nbsp;&nbsp; Perhaps using a CIN linked to the correct openCV DLL
with TColor, TDepth, and String as inputs...... but what would the output be if the output is expected to be a picture?
&nbsp;
&nbsp;
Tim C.
2008-08-05 20:10:06 UTC
Permalink
I had ran into the intermiting wrapper issue before and adding everything to a project seemed to help too....
Tim C.
2008-08-05 19:10:21 UTC
Permalink
Is there a way to have a path converted to a .NET refnum?
&nbsp;
&nbsp;
smercurio_fc
2008-08-05 21:10:06 UTC
Permalink
That is the constructor for the Image class in that namespace. This constructor uses generics, and, as I noted, as far as I know the LabVIEW &lt;--&gt; .NET interface still does not handle generics. This means that none of the constructors for that class would be visible. You also need to make sure you use proper terminology. The "item" that you're referring to is a constructor, not a hook. There are no image "parameters". Those are all constructors. The Call Library Function and CIN are two totally different things. Neither of those can be used to call .NET assemblies. I wasn't suggesting to use Call Library Function to call this .NET assembly. I was suggesting to use Call Library Function with the original OpenCV library since the emgu library is just a .NET wrapper around the OpenCV library. If you can't use the emgu .NET library from LabVIEW, then you need to see if you can use the original OpenCV library. You would be able to do this if a DLL is provided for that library. Unfortunately, this will be considerably more complicated. As I also pointed out, your other recourse is to write your own .NET wrapper around the emgu .NET library.
Tim C.
2008-08-06 00:10:05 UTC
Permalink
Sorry for the language barrier on the terms as you can probly tell I am muttling my way through this exercise.&nbsp;
I am on the same page with you as far as using the Call Library Function Node,&nbsp; my question regrding that is what type of output would be required?
&nbsp;
&nbsp;
smercurio_fc
2008-08-06 14:40:11 UTC
Permalink
That is completely dependent on the function that you're calling. The node simply calls a DLL function. The function's prototype will fully define the inputs and return value. You should peruse the chapter in the LabVIEW Help on calling external code using the Call Library Function function. There is also an extensive example that ships with LabVIEW. Search for "dll". The example is called "Call DLL".
Tim C.
2008-08-06 14:40:12 UTC
Permalink
I found the LV document "Calling External Code"&nbsp; I am going to work through the examples and then pick this endevor back up....
&nbsp;
Thanks for your help so far.
Tim C.
2008-08-06 14:40:13 UTC
Permalink
Sorry, it was called "Using External Code in LabView".....

Loading...