Method to determine shutter count from raw file


Status
Not open for further replies.

toasty

New Member
Apr 8, 2003
400
0
0
Singapore, near NUS
Visit site
I just want to share a sorta successful attempt I made at divining the shutter count on a DSLR, using emacs. The method is to open 2 raw images from consecutive shots from a camera, and search for where the images differ. It would be best to make the 2 images as identical as possible, to minimize the differences. So I shot 2 photos with the lens cap on, smallest aperture, and fastest shutter speed, to get 2 black photos.

I use emacs from the Linux environment and will try to take you through the steps so you can also work out the shutter count for your DSLR. I was doing this with images from a 1D mk 1. The files are smaller and faster to process, than from a 1Ds mk3 (for example). I think emacs should exist on windows and mac platform, but I have not experience with that. I am using knoppix which is a free linux on CD (or DVD). Basically you download the knoppix DVD and burn the image to a DVD-R. There are many mirror sites you can get Knoppix from at http://knopper.net/knoppix-mirrors/index-en.html. Note when you burn the DVD, don't copy the .iso image as a file. You need to transfer that 4G file, byte by byte to DVD. In Nero, there is a burn image option that you should use.

Put the new DVD in the drive, and reboot the computer. The operating system will boot from the DVD and after several minutes, you'll be in the Knoppix environment. Knoppix policy is to not modify the HDD. You can open a terminal window from the task bar at the bottom. The filesystem you'll be seeing, in knoppix is most probably a RAM disk, instead of your HDD. Getting the files from your camera into Linux,itself can be more complex than in windows if you don't know how to do it. You can plug your compact flash card reader into a USB port, and hopefully Knoppix will auto-detect it and ask you if you want to mount it. Typically Knoppix will mount your external drives at the /media/ directory. Your inserted CF drive may be named /media/sda1 or /media/sdb1 or something like that. If Knoppix doesn't mount it for you, then you can try to mount it manually by opening a terminal and typing a line like this:

$ mount /media/sda1

/media is the place where knoppix mounts external media devices like the USB CF card reader. sda1 is the name of the block device that knoppix associates with your card reader. It may not necessarily be called sda1. type:

$ dmesg | tail

To have a look at what hardware Knoppix has detected. Reading through that, you ought to be able to determine the name that Knoppix has assigned to your card reader. Once it is mounted, go to that directory:

$ cd /media/sda1

then go to the directory where your photos are eg:

$ cd DCIM/6408EOS1D/

BTW, you can auto-complete by pressing the tab key. Copy the files to your home directory, you might like to put them in a subdirectory

$ mkdir ~/photos
$ cp * ~/photos
$ cd ~/photos

note: ~ denotes your home directory, which is /home/knoppix
you can now unmount your CF card reader and remove it from the system.

$ umount /media/sda1

Now you can start poking around inside the raw files to see what information you can extract.
You want to open both files in 1 emacs sessions, for example:

$ emacs 910B7000.TIF 910B7001.TIF&

The & at the end asks emacs to run in the background. You can omit if you like, but then your terminal will be waiting for the emacs process to finish before you can do anything else. Once inside emacs, you should get a split screen with the 2 binary files displayed. It will look like garbage, as the information is not very meaningful to humans. You can change to a different editing mode in emacs called hexl-mode. Go to the upper pane, and type M-x hexl-mode. I am using standard emacs notation here. C-k means hold down the control-key and press k. M-x means hold down the meta key (which is normally the alt key) and type x. C-M-x means hold down the control and meta (alt) keys, and type x. M-x is a special emacs key-binding which allows the user to type the name of a command in a mini-buffer for emacs to execute. In this case, we are changing to hexl-mode, by typing hexl-mode after M-x. After a few seconds (depending on the size of your raw file) the display should change to something resembling this:

000016a0: 0700 0801 0900 0a00 0b00 0c00 0d02 0e00 ................
000016b0: 0f00 1001 1100 1200 1300 1400 0040 0000 .............@..
000016c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000016d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000016e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
000016f0: 0000 0000 0000 0000 0000 0000 0032 003f .............2.?
00001700: 00f0 0010 00a8 0010 0070 0008 0003 0004 .........p......
00001710: 000e 0015 0060 0100 0020 0010 0020 0004 .....`... ... ..
00001720: 0082 00ff 0002 0000 0001 0001 0002 0012 ................
00001730: 0000 4f35 0000 0000 0000 ffff ffff 0001 ..O5............
00001740: 4a00 0000 0400 0000 0018 0000 0000 0003 J...............
00001750: 1544 08a8 020f 0251 0005 1770 0001 0000 .D.....Q...p....
00001760: 000d 0000 0000 0000 0000 0000 0000 0000 ................
00001770: 0000 0000 0000 0000 0000 0000 0000 0000 ................

The left hand column is the address of the bytes, starting from 00000 up to the maximum value (size of the file). Then come 8 batches of 4 numbers. They are hexadecimal representation of 16 bytes, grouped 2 bytes, by 2 bytes, for visual readability. On the right, is the ascii representation of those 16 bytes.
That is hexl-mode and you can edit the bytes now, instead of editing characters. But we don't want to edit them, we just want to inspect them for differences. Do the same thing for the other window (which holds the other raw file you loaded when you started emacs), converting it to hexl-mode. You now want to use another emacs tool to find the difference between 2 buffers (a buffer is simply the file loaded into memory that you can tinker with). For this, I normally use the mouse to go to the emacs Tools menu, then scroll down to Compare (Ediff). Tell ediff to find the difference between 2 buffers, and choose the 2 buffers that you've already loaded into memory, and are currently viewing in hexl-mode (you can probably just press return twice). Ediff will highlight the differences between the 2 buffers. Now it's a matter of scrolling through the buffers looking at the differences, which hopefully are not too many. emacs can scroll up and down quickly using M-v and C-v keyboard bindings. When you come to a difference between the 2 buffers, look for a place where the hexadecimal numbers differ by 1. For example, the above printout is from my raw file 910B7000.TIF, the below is from my raw file 910B7001.TIF:

000016f0: 0000 0000 0000 0000 0000 0000 0032 003f .............2.?
00001700: 00f0 0010 00a8 0010 0070 0008 0003 0004 .........p......
00001710: 000e 0015 0060 0100 0020 0010 0020 0004 .....`... ... ..
00001720: 0082 00ff 0002 0000 0001 0001 0002 0012 ................
00001730: 0000 4f36 0000 0000 0000 ffff ffff 0001 ..O6............
00001740: 4a00 0000 0400 0000 0018 0000 0000 0003 J...............
00001750: 1364 08d0 0219 027d 0005 1770 0001 0000 .d.....}...p....
00001760: 000d 0000 0000 0000 0000 0000 0000 0000 ................
00001770: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001780: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001790: 0000 0730 3600 1570 7800 4770 cd00 75e0 ...06..px.Gp..u.

After comparing these 2 buffers using ediff, I found that line 00001730 is different between the 2 buffers in position 1732 and 1733. The values above are 4f35 while for the second file, it is 4f36. I then poked around in several other files shot long ago by my 1D, and found that the number there consistently seems to increase with time. I have no proof, but at this time, I suspect that is the shutter count for my camera. 4f35 = 20277. So I am taking that to be the shutter count of my camera. This is not 100% or for certain, but I think it is likely the shutter count.

I haven't tried this method rigourously on many different cameras, but I suspect it should work whichever camera you are using, so long as the camera stores the information in the raw file.
 

Very tedious isn't it. There are quite a few types of freeware to use. Am I rt?
 

Wow! why would you want to go through trouble to download and install knoppix???:dunno: Are you aware that MacOS is a Unix variant (Darwin) and it also have emacs utility? :dunno:
 

Wow! why would you want to go through trouble to download and install knoppix???:dunno: Are you aware that MacOS is a Unix variant (Darwin) and it also have emacs utility? :dunno:
I don't have a mac. So I'm just showing the method I did it. You can start with emacs on the mac, directly, it'll be simpler for those who already have a mac. I already have knoppix and work using it, so I just put the part about getting knoppix for those people who haven't done it yet.
 

Sorry. But for whatever reason, I was under the impression that you are a mac user. Don't know why...:dunno: hahaha...
 

Maybe one of those freeware Windows/DOS hex-editors can do the same thing?
 

wow very chim. i have to salute you for discovering this tedious method.
 

Status
Not open for further replies.