Re: Problem concerning accessing external library in IDL6.0 [message #47746] |
Thu, 02 March 2006 09:55  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
yingjie, Peng wrote:
> Thanks for your kind reply. I think the problem is that the library
> which I used (DirectX.Capture.dll) is COM object, but it is not an
> ActiveX library. It is a .NET library. In .NET framework, you do not
> need to (or simply you can't) register the .NET library. This
> function is used to simplify coding within the .NET framework, such as
> C#. However, for us, the IDL user, we can't use ActiveX control to
> access this kind of library any more since we can't get the CLSID.
Are you *sure* you can't get the CLSID? Again, I am not a .NET guy, but
I see a ".NET Category" in my COM/OLE browser. I can then look for
something that I might be able to find docs or guess a method... I see:
"System.Random"
I use the COM/OLE browser to get the CLSID and then create the IDL COM
object:
test=obj_new('IDLcomIDispatch$CLSID$4E77EC8F_51D8_386C_85FE_ 7DC931B7A8E7')
I then try to guess a method or two, and fail. Then I go to the VS .net
docs, find the .net random class, see that the method to get a random
number is "next" and voila!
IDL> print, test->next()
1957853535
IDL> print, test->nextdouble()
0.80895216
IDL> print,test->tostring()
System.Random
IDL> print,test->gethashcode()
54267293
So I think you should at least *try* to find the CLSID using the COM/OLE
browser. I mean it will only take a few minutes and you may save
yourself a lot of time.
If you do find the CLSID, you still may not be "out of the woods" as we
say. I have had mixed success with IDL's COM interface. Simple things
tend to work, but more complex methods can run into problems. For
example, the nextbytes method of our aforementioned system.random object
seemed very straightforward. It fills a byte array with random bytes.
So you would think it would be as easy as:
IDL> a=bytarr(5)
IDL> print, test->nextbytes(a)
IDLCOMIDISPATCH$CLSID$4E77EC8F_51D8_386C_85FE_7DC931B7A8E7:: NEXTBYTES:
Unable to call method NEXTBYTES.
The parameter is incorrect.
I tried numerous variations with no success. I'm sure there is a
reason, and maybe some way to get it to work, but my point is that it
isn't always smooth sailing on the IDL COM seas.
So in the end you may end up writing a DLM anyways. It isn't as hard as
it may seem, especially if you buy Ronn Kling's book "Calling C from
IDL". You can order it from his website www.kilvarock.com.
Good luck!
-Rick
|
|
|
|
|
|
Re: Problem concerning accessing external library in IDL6.0 [message #47756 is a reply to message #47755] |
Wed, 01 March 2006 14:52   |
yingjie, Peng
Messages: 11 Registered: March 2006
|
Junior Member |
|
|
Hi, Rick
Thanks for your kind reply. I think the problem is that the library
which I used (DirectX.Capture.dll) is COM object, but it is not an
ActiveX library. It is a .NET library. In .NET framework, you do not
need to (or simply you can't) register the .NET library. This
function is used to simplify coding within the .NET framework, such as
C#. However, for us, the IDL user, we can't use ActiveX control to
access this kind of library any more since we can't get the CLSID.
BTW, do you have any library or do you know where I can find some
library to control a web cam from IDL? Thanks a lot.
Yingjie, Peng
Information Department VII
University of Wurezburg
Germany
|
|
|
Re: Problem concerning accessing external library in IDL6.0 [message #47773 is a reply to message #47756] |
Tue, 28 February 2006 13:41   |
ronn
Messages: 123 Registered: April 1999
|
Senior Member |
|
|
Hi Peng,
Have you tried using Randall Frank's Video For Windows dll on my
website?
http://www.kilvarock.com/freesoftware/dlms/randallfrank.htm
I am currently using it to control a web cam from IDL and it works
great.
Here is a simple test procedure that you can use
pro testVFW
if VFW_PRESENT() eq 0 then begin
void = dialog_message('No Devices Found!')
return
endif
err=VFW_LIST(names,descs)
print, 'These are the devices found'
location = -1
for i=0,n_elements(names)-1 do begin
print, names[i], descs[i]
;find the webcam
if strpos(strupcase(names[i]),'WEBCAM') ge 0 then location=i+1
endfor
if location eq -1 then message,'No WebCam found'
err = VFW_CONNECT(location)
if err ne 0 then message,'Cannot connect to Webcam'
err= vfw_dialog(1)
err = vfw_grab(image, info)
window,0,xsize=(info.dimensions)[0],ysize=(info.dimensions)[ 1]
tvscl,image,/true
for i=0,10 do begin
err = vfw_grab(image, info)
tvscl,image,/true
endfor
return & end
thanks,
Ronn Kling
KRS, inc.
email: ronn@rlkling.com
Use these books to upgrade your IDL skills.
"Application Development with IDL"
"Calling C from IDL, Using DLM's to extend your IDL code". SECOND
EDITION includes C++ and debugging!
"Power Graphics with IDL, A Beginner's Guide to Object Graphics",
|
|
|
Re: Problem concerning accessing external library in IDL6.0 [message #47782 is a reply to message #47773] |
Tue, 28 February 2006 10:51   |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
yingjie, Peng wrote:
> I am a master student in Germany. Now we are planning to use IDL 6.0 to
> develop software for our smart rover robots. This project requires the
> software should be able to capture video from a camera (e.g. a Webcam).
> It seems to me that it's almost impossible to complete this job
> purely in IDL.
Well, yes and no. If your webcams are networked then you can grab
images using IDL's SOCKET procedure. Those interfaces tend to be slow
though which may not work for your application. If your webcams are
serial/USB based then yes, you will need to use one of the external
interfaces provided by IDL.
> So we plan to use a well developed class library
> (DirectX.Capture.dll). Since I am not very sure about how to use an
> external library, the only way for me is to use ActiveX Control to
> access this library. In order to get the COM object's class
> identifier (CLSID), I try to use the command line below to register
> this library: regsvr32 DirectX.Capture.dll. Unfortunately, I received
> an error message: the DirectX.Capture.dll is loaded, but cannot find
> the DllRegisterServer entry point and the registration failed. The
> reason I finally figured out is that this library is a .NET library,
> which do not need to be registered under .NET framework. But without
> the CLSID, I have no idea how to use ActiveX control to access this
> library anymore. Could you please give me some idea how to achieve this
> requirement? Thank you very much for your kind assistance!
Does that library implement a COM/ActiveX interface? (I'm no COM expert
but the error makes me think it doesn't.) If it does, you should be
able to get the CLSID using the COM/OLE viewer which ships with MS
visual studio and can also be downloaded for free from MS.
I would start with the docs for the capture library and determine what
interfaces it provides. Then it would be worth your time to read the
external development guide ($IDL_DIR/help/edg.pdf) to learn about the
different methods for accessing external libraries. With that
information you should be able to determine the best technique and move
forward from there.
-Rick
|
|
|
|