Using External Code Scripts

Want to move your code and projects to LiveCode but don't know where to start?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller

Post Reply
hairydalek
Posts: 57
Joined: Sat Feb 01, 2014 8:57 pm

Using External Code Scripts

Post by hairydalek » Mon Jan 18, 2016 10:36 am

HI,
I’m fairly new to LiveCode. It’s been suggested to me that I look at something I’ve written as an Automator Action (Mac folk will know what this means) and make it cross platform by making it a Live Code project. It sounds like as good idea, as the problem I am solving is one that Windows folk will experience as well as Mac folk.

What my Automator Action does is take images from a spherical camera, grabs the EXIF data (which is manufacturer specific) and levels it - so that the horizons is always level. The problem I can see is that this script uses a number of code libraries to achieve this. The Exif data is collected using ExifTool. The levelling is done by calling a few bits of code from Hugin (a free panorama stitching application). My Automator Action loops through a batch of images, passing them to a shell script in the Action. That shell does the actual work - grabbing Exif data, preparing the data that the code then uses to process the images.

So, what I need to know is if this is possible to roll into a cross platform (Mac, Windows, possibly Linux) Live Code project. There is a Windows version of Hugin, so the libraries used should be useable on the platform. I’ll need some pointers too on where to look for more information on bolting this together, as I’m not that familiar with Live Code. Lots of head scratching on my part, but it will be worth knowing if this is even possible before I start.

Thanks.

Jeanne DeVoto
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10
Joined: Wed Apr 12, 2006 12:23 am
Contact:

Re: Using External Code Scripts

Post by Jeanne DeVoto » Mon Jan 18, 2016 5:21 pm

I think breaking the application down into tasks is the first step, just to get clarity.

So if I understand correctly, the needed Hugin commands can be called from the shell on both OS X and Windows, and they do the meat of the application. Your LC application will need to:
- get the list of images (are these images in a folder? User-selected? In the connected camera? are subfolders involved?)
- get the EXIF from each image (used by Hugin?)
- execute some shell commands to generate the leveled image (is there logic in this script, conditional branches, etc, or is it just a list of commands?)
- wrap this in a reasonable user interface

Is that about the size of it? If so, it seems completely do-able in LC.

hairydalek
Posts: 57
Joined: Sat Feb 01, 2014 8:57 pm

Re: Using External Code Scripts

Post by hairydalek » Mon Jan 18, 2016 8:10 pm

Jeanne DeVoto wrote:I think breaking the application down into tasks is the first step, just to get clarity.

So if I understand correctly, the needed Hugin commands can be called from the shell on both OS X and Windows, and they do the meat of the application.
Yes. What they do is level an image then with a Ricoh Theta. This is more involved that rotating an image - it’s a full 360x180 panoramic image, so the Hugin commands are needed to ensure that it’s all done properly.
Jeanne DeVoto wrote: Your LC application will need to:
- get the list of images (are these images in a folder? User-selected? In the connected camera? are subfolders involved?)
- get the EXIF from each image (used by Hugin?)
- execute some shell commands to generate the leveled image (is there logic in this script, conditional branches, etc, or is it just a list of commands?)
- wrap this in a reasonable user interface

Is that about the size of it? If so, it seems completely do-able in LC.
Basically, it’s as set of commands which walk through each image, extract the data needed, roll it upon a file that the Hugin tools need to do their job, and then cleans up after itself. No branches or conditionals yet - but when I add error checking there will be.

Most of this I have working. The UI is a bit rubbish, but that can change later. All the files needed to process the image are created and are what is expected. I think it may be possible to extract the tools that ship with Hugin and use them on their own - but i need to find more about them first. So things are heading in the right direction.

My main question is how I could get these tools, which run on Macs in Bash, to be called and to run on Windows. I’ve had a couple of options suggestions - using LiveCode Server, or MSys (which I’ve not heard of before). This is an area I know very, very little about. I clearly need to read up on this some more, but I expect that others have already navigated this particular stream, and hopefully can offer some sage advice.

Jeanne DeVoto
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10
Joined: Wed Apr 12, 2006 12:23 am
Contact:

Re: Using External Code Scripts

Post by Jeanne DeVoto » Tue Jan 19, 2016 2:26 am

I'm no expert on the Windows command line, but it looks from the documentation as though you can use the Windows shell for the individual commands. If this is the case, you can do the logic in a LC script, and store interim data in a file if need be.

hairydalek
Posts: 57
Joined: Sat Feb 01, 2014 8:57 pm

Re: Using External Code Scripts

Post by hairydalek » Tue Jan 19, 2016 2:09 pm

And YAY! I have an app that works in Windows and Mac OS! I had a think about this last night, and as Hugin supplies much the same tools for the Windows and Mac versions (the Mac is slightly behind, so things need to be done slightly differently), I decided to try just changing the path to the tools I needed depending on the platform. And that seems to be all I needed. Everything else - parameters etc. were all the same.

I’ll need to do more testing, but what I am getting out of the Mac version appears to be the same as what I am getting out of the Windows version.

I was expecting to have to throw my scripts at some kind of Bash interpreter on Windows, and I ended up over thinking it. I bit of time away seemed to have helped enormously.

Thanks for your input, Jeanne.

Post Reply

Return to “Converting to LiveCode”