SyntaxHighlighter

Tuesday 16 July 2013

Day 27: lftp mirror, AR materials, unable to load ALVARWrapper.dll

The issue yesterday about kiss rejecting rsync commands? All fixed using, lftp mirror as an alternative. Need to install lftp on Cygwin on both AR and 123D machine. Some quick and friendly documentation on lftp and it's awesomeness here.

The get.sh file goes on the AR machine to grab the texture/model files:
Lovely code:
#!/bin/bash
# get.sh
# mirror a remote folder, copying new files to local dir
# 
# pull files from: public_html/123/incoming
# (toby@kiss.cs.man.ac.uk)
# to: the directory this script is run from
#
# Non recursive, resumes partial files in case of interruption
# Uses dir cache for speed
#
# last edited: 16/07/2013 by Hamza Mahmud 
#
lftp -u toby,********* kiss.cs.man.ac.uk << EOF
mirror -cr --use-cache public_html/123/incoming .
quit 0
EOF

And a similar put.sh file goes on the 123D machine. There will be a folder on the 123D machine in which the 123D operator will paste all models and textures. They will initially run a script that will call this put.sh file every minute or so to update the remote dir.

Similarly on the AR machine a script will be running that calls get.sh every minute.

Automation of syncing files across AR and 123D machine is now almost done. If we recall steps 1 to 5 of the final 123D AR workflow:
  1. At the 123D Catch machine, take bunch of photos, run 123D Catch on them and export a model.
  2. run the put.ftp script to upload the model and its texture to our file store.
  3. On the AR machine go to C:\Export\toby, run get.ftp (this script pulls the 123D models from our file store somewhere)
  4. rename texture file to "t1.jpg" so now we have e.g. 1.fbx and t1.jpg
  5. Use regex to replace 4 lines in fbx
I now need to construct a script that will run on the AR machine, that will call get.sh every minute, and whenever a texture and model is grabbed will rename textures and replace the relevant lines in .fbx's. Here we go.

I should really get in touch with a shell scripting expert...

But in a fit of impending excitement I started relearning and revising some basic shell scripting. Made a few notes:
">" redirect stdout, e.g. to a file
ls -l > file

"<" means command before it take input from source after it:
grep searchterm < file

">>" append stdout to a file
date >> file

"2>" redirect stderr to a file

| redirect stdout from previous command into next command
ls -l | grep searchword | sort -r

make variables by "=", no spaces:
msg1=Hello

" " enclosing means treat everything inside as literal except certain keywords (escape char \, $ for vars)
' ' means take as literal, no exceptions.

reference variables with $, can use braces so that you can put characters immediately after it
"$msg1 World!" -> prints Hello World!
"${msg1}oooooo!" -> prints Hellooooooo!

command line arguments:
$# parameter count
$@ all parameters separated by spaces (useful for passing the params to another function or program)
$- the flags the shell was invoked with (useful for controlling program flow based on flags set)
$$ process if of the shell innovated to run the script (useful for creating temporary unique filenames
relative to this instantiation of the script

command substitution: output of the command substituted in place of the command name
$(command)
`command`

arithmetic expansion (value of expression replace the substitution)
$((expression))

if list
then list
[elif list
then list] ...
[else list]
fi

if conditions evaluated via the "test" command, evaluates to true = returns 0 (false returns anything else)
test is equivalent to enclosing in square brackets.
(MUST HAVE THE INCLUDED SPACES)
if [ "$1" = "1"]

Can integrate && and || between tests. Both LAZY (first && fails=will not evaluate second, similar for ||)

[ x -gt y ] <- greater than of the test command (before we had "=" of the test command)

while list
do list
done
"The two lists are executed repeatedly while the exit status of the first list is zero."

for variable in word ...
do list
done
"The words are expanded, and then the list is executed repeatedly with the variable set to each word in turn."

OR CAN REPLACE DO AND DONE WITH { AND } - can't do with while loop.
for variable in word
{ list
}


Functions:
name() {
commands
}
   
And came up with this simple highly amateurish framework for automated code:
#!/bin/bash
ls . > /tmp/old-list
while :
do
 echo "Welcome to the AR process script. It's now running, you can relax."
 /bin/bash get.sh # runs the lftp mirror command to grab new files
 
 ls . > /tmp/current-list
 if diff /tmp/current-list /tmp/old-list
 then
  # we have new files!
  diff /tmp/current-list /tmp/old-list | grep '^<' | while read x file 
  do \
     # do something with new files $file
     echo $file
     mv $file gotten/
     awk '$file {print $2}' > awk-log
  done
 fi
 cat /tmp/current-list > /tmp/old-list
 sleep 1
done

This gives a list of any new files that appear in the import directory at the point inside the innermost while loop (line 13). Unfortunately the commands after the do of the innermost while loop aren't being executed when this is run as a script. Not sure why as of yet.

After this failed attempt I've decided it isn't worth me devoting more time to the shell scripting until after I've finished the other task of automating content building, since the shell scripting can easily be done by an expert.

AR Materials

The little Animation13 signs we used last Friday were printed on a sturdy, rigid plastic board that Toby noticed would be perfect to use as Marker cards.

I set about researching where we could source such material, and came across sheets of foam PVC whose description and image resembled the A13 signs quite closely: http://www.brettmartin.com/en-gb/plastic-sheets/products/foam-pvc.aspx

Aka Foamalux!

Found quite a lot of suppliers of the stuff, and we've ordered some large sheets we will be guillotining to A4 and A3 size to use as AR markers - coupled with A4 size sticky labels to print the markers on and attach them to the foam PVC boards.

Inexplicable problem with ALVARWrapper.dll

Ran the LowryDemo program today and hit the age old error:
unable to load ALVARWrapper.dll the specified module cannot be foundSOLUTION:open  \src\device\vision\alvardllbridge.cs and change ALVARWrapper.dll to full file paththen rebuild GoblinXNA
Implemented (what I thought last time was) the solution, rebuild all, but annoyingly the problem remained.

Ran depends.exe on alvarwrapper.dll, copied ieshims.dll and dcomp.dll to bin/x86 and to dlls/unamanaged still no luck.

Reinstalled .net 4.5, installed Visual Studio SP1, reinstalled opencv and alvar and rebuilt the alvarwrapper dll (opening the alvarwrapper project in Visual C++ Express and rebuilding from scratch, then copying over) and installed every available update from Windows Update. Restarted PC. Copied all dlls from dlls/unmanaged into bin and bin/x86.

Works. Strange, not certain which step was the one that fixed it in the end.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.