fictrac icon indicating copy to clipboard operation
fictrac copied to clipboard

Build a dll with fictrac, to be called from LabView

Open young24 opened this issue 6 years ago • 5 comments
trafficstars

Hi Dr. Richard Moore, my name is Wenbin. I'm now working with Ashwin Miriyala from Scott Waddell's Lab. Ashwin might have talked with you about what we are doing now. Basically, we want to incorporate your excellent tracking program into another labview program. So that we can make a close control loop between odor release and fly behaviors. My idea is to build a dll with your Fictrac, then call it from "Call library function node" from LabView. I have walked through basic tutorials about Creating a dll (c++) with VS and Configuring call library function node.

Any guidelines/suggestions for building a dll with your Fictrac? since I noticed that there seem to be several differences between console programs and dll programs.

Thank you in advance and your great Fictrac.

young24 avatar May 27 '19 09:05 young24

Hi Wenbin, the FicTrac software is actually already a library (fictrac_core). The FicTrac executable is just a lightweight wrapper for this library. You'll find the library at fictrac\lib\Release\fictrac_core.lib if you built on a Windows machine. At the moment this library is build as a static library (.lib).

You can convert a .lib to shared library (.dll) by writing a def file, or - more simply - by adding some code to each function you would like to call externally and recompiling as a dll. See, e.g. this page for details.

When I get a chance I can see exactly which steps are needed to build the dll and provide you with some specific instructions - but you're welcome to follow above link and try your self in the meantime :-)

rjdmoore avatar May 27 '19 13:05 rjdmoore

Will just add that Trackball.cpp/.h contains the implementation/interface for the fictrac_core library.

Which functionalities would you want to have access to from Labview? Currently, there is really only one function to call: the Trackball constructor which takes the config file as a parameter, FicTrac will run automatically after that until the image stream ends or until terminate() is called. Do you, for example, want to receive the output data via the API (instead of via sockets, etc), or be able to pause/restart tracking, or something else?

rjdmoore avatar May 27 '19 13:05 rjdmoore

Thank you very much for your response. It's really helpful. Now, we just want to receive the output data via the API. I am going to follow your instructions to convert .lib to .dll. Now, I have more confidence. 😄

young24 avatar May 28 '19 01:05 young24

Ok, currently there is no way to receive the output data each frame via the api - but it won't be hard for me to add a function that you can call to receive the current data. Then you will just have to call that function as often as you want data. Alternatively, I can allow you to register a callback. Not sure how familiar you are with c++ but would either of these approaches work?

rjdmoore avatar May 28 '19 05:05 rjdmoore

Yeah. I prefer the first approach. I'm okay with c++. I managed to write a C++ program called BLITZ which allows a projector, cameras, relay, and online image processing talking with each other. However, I have to confess compilation is always a headache to me, I'm heavily relying on what MSVS can provide me.

young24 avatar May 28 '19 06:05 young24