HDR using Linux, in bulk, via Command Line

HDR
Have been playing with HDR after going out doing some photography. Problem was that i was having to do the entire process of merging all images before i even knew if i had a viable image to do some ‘making pretty’ too.

I figured, i should be able to script this, how hard can it be?

Turns out, fairly easy!

First i removed any images that were not part of an HDR sequence, so all HDR were left and in numeric order. Then I made a dir for each ‘set’ of 3 images and moved them into that using the following shell script

n=0; y=1 ; for i in *.CR2 ; do  mkdir hdr-${y} ; n=$(($n+1)) ;echo image number $n ;  mv $i hdr-$y/ \
 if [ $n -gt 2 ] ; then echo resetting $n and $y ; n=0;y=$(($y+1)); fi ;  done

I then found this script which saved me having to write anything else much http://linuxdarkroom.tassy.net/hdr-creation-script/ .This does require a few things installed as dependencies, but nothing overly major.

Now making and HDR is as simple as running

for i in  Photos/2012/06/HDR-hamilton-gardens/* ; do echo doing $i ; ./createHDR.sh $i ; done

Bingo, now i have 40 or so HDR automatically generated as an xcf in gimp, with a layer for each effect so i can open them all, weed out the crap and tweak anything else!

I did end up editing the script since i did not like the default end result, i found i kept changing the fattal layer to be a HARDLIGHT_MODE instead of OVERLAY so it had a stronger feel, then i also added in the following to take down the brightness and saturation.

 (gimp-brightness-contrast fattallayer -60 15)
(gimp-hue-saturation fattallayer 0 0 0 -20)

HDR

Finding a Flash video in chrome – Saving files open but deleted

Flash movies are online, but sometimes i want to save some for offline usage so i can watch them later or offline (laptops) etc.
Often there is no way to save/download these files, but they are not held in the tmp dir or cache as they used to be due to changes in flash. In Linux this is easy to overcome using the following methods. This also works for any file that’s been deleted but is still running in memory.

First, you need to find what or where the file is. For flash try

velofille@apple:~$ sudo lsof |grep Flash
npviewer.  8774  velofille   16u      REG                9,1 253092771     396153 /tmp/FlashXXDfgiS7 (deleted)
velofille@apple:~$ 

Bingo, i found my file! Of course the file /tmp/FlashXXDfgiS7 is deleted, so i cant just copy it like the good old days. Now i can copy that file from the proc filesystem using the following

cat /proc/8774/fd/16 > movie.flv

Now to breakdown where i got those parms from. The 8774 is the pid and 2nd number on the line, the 16 was from the ’16u’ which is the file descriptor . So when you do your lsof you can change those according to what you have open.
To find files open from a particular app, use ps to find the pid, then use

lsof -p 8774

Output is something like this

chrome  26572 velofille  mem    REG                9,1  1285536   1836431 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
chrome  26572 velofille  mem    REG                9,1   141088   3146088 /lib/x86_64-linux-gnu/ld-2.13.so
chrome  26572 velofille  DEL    REG               0,16           34257353 /dev/shm/.com.google.chrome.i96CPN
chrome  26572 velofille  DEL    REG               0,16           34257687 /dev/shm/.com.google.chrome.W9M2O5
chrome  26572 velofille  mem    REG                9,1   377352   4587538 /opt/google/chrome/libppGoogleNaClPluginChrome.so
chrome  26572 velofille    0r   CHR                1,3      0t0      5778 /dev/null
chrome  26572 velofille    1u   REG               0,20   953173   5767170 /home/velofille/.xsession-errors
chrome  26572 velofille    2u   REG               0,20   953173   5767170 /home/velofille/.xsession-errors
chrome  26572 velofille    3u   REG               0,20   953173   5767170 /home/velofille/.xsession-errors
chrome  26572 velofille    4r  FIFO                0,8      0t0  34257284 pipe
chrome  26572 velofille    5u  unix 0xffff88002c61f740      0t0  34257940 socket
chrome  26572 velofille    6u  sock                0,7      0t0  34257281 can't identify protocol
chrome  26572 velofille    7u   CHR                1,9      0t0      5783 /dev/urandom

The only ones you can take like this are the ones with a file descriptor to play with.

Good luck, an have fun!

Getting the RT3070 USB wifi adapter working in linux

Ralink must be one of the shittiest Linux supported network cards ever. I have a friend who’s not so good on computers, to the point where after reinstalling every  week for 3 weeks i suggested linux.

That sure saved me a lot of long drives to fix whatever went one, i could fix it with SSH. This has worked out great for both of us, especially since i moved 200 km away. She began on linux and is used to how it works, she loved it when we moved to ubuntu and she could install and remove things herself, and run updates.

Anyway, i digress, shes moving house on the coming weekend, and has a few coins leftover, and she wants to move to a wireless network. I thought “great! Linux support for most usb wifi isn’t too shabby, ill get something that works ‘out of the box’ if i can”. I went to ascent.co.nz and found this cheap card that said ‘Linux Compatible”. Well, I guess it was hoping for too much , but wasn’t expecting the problems i had.

The drivers on the cd wouldn’t compile because of the age/code/dependencies. I went to the ralink website and downloaded the latest drivers ( DPO_RT3070_LinuxSTA_V2.3.0.2_20100412 ). I ran into problems right away compiling for various reasons. Eventually i followed the following recipe to get this going.

unpackage it ;

cd DPO_RT3070_LinuxSTA_V2.3.0.2_20100412/
vi os/linux/usb_main_dev.c

Look for the following line
MODULE_DESCRIPTION(“RT2870 Wireless Lan Linux Driver”);
And add this one below it
MODULE_LICENSE(“GPL”);

Exit the editor, then do the following

sudo make
sudo cp RT2870STACard.dat RT3070STACard.dat
sudo cp RT2870STA.dat RT3070STA.dat
sudo make install
cd /etc/Wireless/
sudo ln -s RT3070STA RT2870STA
cd RT3070STA
sudo ln -s RT3070STA.dat RT2870STA.dat
sudo modprobe rt3070sta

if that works, throw the module in /etc/modules  (just the name rt3070sta ) so it loads on boot.

Now the key to all this is that ralink are cheap. They give a chip a new name, even though its clearly the same as previous ones. They do a quick run over the code to change all instances of 2870 to 3070 and of course forget half them, this is why there are odd cp’s and having to link thinks to work.

It seems that debian based distros like/need the GNU in the file, which seems to have been moved into another file in these drivers and its not registering. By adding it in it will load and work.

Let me know if this has helped you 🙂

Refs : http://www.linuxforums.org/forum/wireless-internet/161550-rt3070sta-module-license-unspecified-taints-kernel-solved.html