WWDC2001 Session 117

Transcript

Kind: captions
Language: en
good morning everyone I'm Travis Brown
and the imaging technology manager for
Mac os10 and I want to welcome you to
session 117 image capture framework
you've already seen image capture
demonstrated on the keynote where you
can take a USB digital camera plug it
into a USB cable and Mac os10 will
recognize that a cameras been plugged in
and will then bring up a very
lightweight image browser to enable the
user to select which pictures they wish
to download there's another dimension to
image capture and that is the image
capture framework underneath image
capture there is a set of api's that
developers can use to make their
applications savvy with digital cameras
so therefore you can easily take a
application such as a database
application where you might want to give
a field that could essentially capture a
camera an image off a digital camera and
put that in a database that would be
possible to do using the framework
there's all sorts of very interesting
possibilities for applications to create
new features for their users in
conjunction with digital cameras when
the real interesting points is I want to
point to some statistics is the digital
camera market is exploding it's one of
the fastest growing computer peripherals
available and you have an interesting
statistic is that you know eventually
that digital cameras will fairly soon
surpass that of film cameras so in terms
of the way users will interact with
photography and images in the future
that'll very much be driven by digital
cameras so it really makes sense for
your applications to become aware of how
to you know work with digital cameras
and add value
an additional interesting point that was
brought up in the keynote is that of Mac
users 60% of them have digital cameras
and they would really love to have a
seamless integration their applications
with their digital cameras so now I'd
like to invite Steve swin on stage to
continue the presentation
[Applause]
Thank You Travis
good morning before we start talking
about image capture from Mac os10 let's
review the current situation
micros 9 as you know Mac OS 9 has no
system level input architecture
implemented so all the major device
manufacturers have to do is shipping
custom applications and drivers and
sometimes Photoshop plug-in applications
will have a hard time working with
devices because doing so requires
knowledge of device level communication
that means you have to know how to talk
to each individual device using a device
protocol so image capture for Mac OS 10
what we're trying to do here is provide
a device level abstraction so that would
enable the applications and the device
communicate through this abstraction
layer very easily it's a collection of
api's and setup system services like I
said before enables application easy
access to imaging devices such as
digital camera we also provide ever a
very tight system level integration to
take advantage other Apple technologies
such as QuickTime color sync and quartz
here's a block diagram view of image
capture framework to see the bottom
layer darwin is the open source kernel
running on top of it is the application
service quartz OpenGL and QuickTime
image capture framework is part of
carbon library however you can access
image capture directly from either
carbon applications or cocoa
applications
there are three major components in
image capture framework the first one
the most critical one is the framework
itself instead of api's we have a high
level API for applications to use and
those are low-level api for devices we
also ship with building the set ability
and support for cameras using standard
protocols I'll get to it later
we also ship image capture application
which is a lightweight application to
allow user to preview and download
images from camera here is a another
view of image capture framework you see
on the left hand side you have your
camera once you connect the camera to
the computer image capture will load the
right camera module for that device and
then your application and image capture
application can communicate with this
camera to this device abstraction layer
and using the image capture framework
api's so we have a built in camera
support for four different class of
devices the first three are camera
devices they use protocols and so you
can connect the camera directly to the
computer they use P DP Class D stock
class and mass storage class we also
support a number of removable media P DP
class PD P stands for picture transfer
protocol it's also known as pima 15 740
pima is the standard organization
defined a standard it's an industry
standard group and including platform
vendors like Apple Microsoft and device
manufacturers such as Kodak and Sony
this protocol enables full control of
camera functions so you can set the
camera exposure level and you can take a
picture you can retrieve picture can
synchronize clock
or even you you can download music files
it's very powerful protocol it is
transport independent the USB working
group has defined the class for the PDP
device already and malkos 10 10 point Oh
our first implementation support a set
of PDP commands that would enable you to
do quote unquote plug and join
operations typically you go out and take
whole bunch of pictures and you come
back and plug your camera into the
computer we can download all the images
for you
recent cameras from Kodak and Sony
support this protocol so if you want to
get experience how this camera of PDP
protocol works for you or you want to
test whether your application can get
one of those Kodak cameras like 4800 or
mc3 or Sonya 75 there are more on the
market today the second class is destock
class this is a vendor specific protocol
by flash point technology some Kodak and
HP cameras using this protocol since
it's a vendor specific protocol we rely
on the device name matching to load the
proper module to support your camera so
if your camera uses this protocol let us
know so we can add into our database
third class is mass storage this is the
most commonly used protocol
it basically mounts the camera to
storage devices as a ms-dos file flat
file system on your desktop so the
advantage of doing this it's a pretty
simple to eat easy to implement and it's
a familiar concept for users to use
however the disadvantage of that is it's
really the limited interface to a camera
because you you the only way to control
that is through file system commands so
you cannot really get and set camera
specific properties
there's a number of removal media we can
support as well
compact flash smart media Memory Stick
Micro Drive and the good old floppy disk
super disc recordable CD this is a good
way to get your image into the computer
if your camera is not USB equipped or
your camera protocol is currently not
supported by micros 10 it's lunch you
can you can take your storage device and
find a card reader and plug it in and as
long as you can mount your storage
device on the under file system we can
read it although the storage device
approach is easy to implement but since
we cannot treat it like a camera so we
cannot ask the camera where you store
your files and are you a camera device
or not so we rely on a few hints first
of all the device has to mount as ms-dos
file system and then we search for does
it have a standard DCF file structure
DCF stands for digital camera file
format which is defined by the standard
organization if we cannot find any of
this stuff and we look for is that this
is one of the non-standard file
structure we stored in our own database
so we try to match that so if you have
the file structure which is not standard
not using ms-dos file system or DCF file
structure or even if you do use a
standard file structure but if you store
the images outside the DCIM folder which
is by default the folder stores still
images however if you have movies and
sound files stored in other folders
please let us know so we can make sure
we search through your folder
and again like PDV camera we cannot ask
the camera for image files in sound
files and audio files video files so we
rely on some standard file formats that
we recognize to download currently mass
storage interface we support JPEG TIFF
and jiff for still image formats video
format we support QuickTime impact and
audio file format with support mp3 again
if you if you store files that file type
not on the list but it's important to
your camera function please let us know
so we can include it in the download so
if your camera vendor there's three
things to remember first of all use
standard protocols PDP or mass storage
both excellent choice you don't have to
worry about getting the driver getting
the support installing software user
experience will be great second one is
also very important send your prototypes
to us to ensure compatibility it's very
important
senator Lee sin often sent Laura
multiple copies engineers can be bribed
and the last one if you have a constant
file structure or a file system make
sure you send us to the the the followed
structure map to a silicon included in
our database third part of image capture
framework is image capture application
this is a lightweight application to
allow you to to browse and download
images from camera devices and also you
can define a set of hot plot actions and
automatic tasks to customize your
workflow we also ship a number of
scripts to allow the user to do common
tasks such as build web page here's the
UI for image capture application the top
part is camera shows you what camera
device you have currently connected you
can have multiple cameras connect at the
same time the middle part defines Hut
plot actions and automatic tasks and the
last part is you specify where you want
to download your files to one thing
about download synchronization camera
devices are increasing in resolution in
an amazing rate and you can find cameras
with with three four or five even six
megapixels on the market today so you
can imagine the file size is getting
bigger and bigger so try to we try to
avoid unnecessary downloads by relying
on a couple of things for Mac OS 10
first of all we use file name and if we
find the camera if I try to download and
you have identical file name in the
download folder already and those are
the size of these two files in the
camera and in the download folder are
identical we'll skip that in the future
we will use the
to date in addition to file name stored
metadata to do the synchronization so if
your application developers make sure
you do not you pre you try to preserve
the metadata don't strip it out and if
your camera vendors because the serial
number the picture serial number is part
of the file name so make sure you don't
recycle the numbers and until you run
out of all the combination how clock
actions hot-plug action is defined to be
when you connect your camera what do you
want to see happen the three
possibilities here the first one is when
you plug in the camera we open the image
capture application for you so you will
see the same UI showing you earlier
the user can browse and download
selected and select images to download
that's the default behavior or you can
select automatically download all the
advantage of doing that is you can
automate the system when you plug in the
camera there's no UI will come up all
the files on the camera would be
transferred to the specified download
folder automatically and if you specify
an automated task and that one will get
invoked and all the download files will
be passed to that application to do post
processing one thing to point out is
even if you select the default you can
download come up with a UI and you can
select which files you want to download
and you can also specify the post
processing automatic task and after
downloading it will call that automatic
task as well so the third action you can
specify is none basically there's
nothing on macros 1010 point or the
first release the idea here is the user
may want to use his own favorite
applications to handle this camera
plug-in event so we will not invoke the
image capture application if you select
this one and in the future
to make this more useful you can
actually select an application with the
lunch when the hot-plug event happens
and we call that application for you
automatic tasks like I said before this
is the post processing after you've
downloaded your images you can spec you
specify this automatic test and we will
call it after we download all the images
they can be Apple scripts applications
or aliases currently you have to store
these things in the library image
capture scripts folder so we can pick it
up in the UI we show you to which one to
select in the future we're gonna put it
into a preference and so you don't have
to you can select it you don't have to
put it into this location to get picked
up so one advantage of automatic tasks
is even though today not too many
applications are image captured Savi
when I say that it's really they don't
really have the API calling API calling
the image capture API to do the that
stuff like getting the pictures
downloaded or sending the pictures do
all this stuff but however if your
application can receive open events with
all this files passed in and you are
benefiting from image capture framework
heretic because in that scenario the
user can select your application it's
post-processing event future directions
for image capture application there are
a few areas we try to improve one is
made a data browser may the data is the
per image information such things as
exposure level your color space your
creation date the size resolution and no
that's good stuff and it helps the
application to use the metadata down the
stream to do better image management and
processing
we also want to improve in the browser
you can do per image rotation and
deletion instead of using a script you
can actually wrote it in the place and
delete without downloading third parties
we're going to add the preference panel
preference panel would allow you to
select like I said before which
application you want to see get lunched
when you plug in a camera and those so
you can specify what are the automatic
tasks you want to see in your user
pop-up menu couple words on scanner
support for Mac OS 10 image capture
would support scanner device in the
future however make sure your porch your
scanner to meckel's 10 today instead of
waiting for image capture couple easy
ways to do that first of all you can
port your Mac OS 9 scanner application
to two-carbon or to Mac OS 10 that's
probably the least effort involved in
some cases or you can support your
scanner device using Twain interface and
just yesterday we had this Twain
announcement that Twain organization is
porting Twain DSM to Mac OS 10 so if you
like to use the twin interface and you
can write a 20s for your scanner device
and shipping that for Mac OS 10 for now
and we'll figure out a way to reach the
back of compatibility once we support
scanner device in image capture natively
so although I know that you guys
probably seen image capture demo many
times this week but hopefully we show
you something different I want to
introduce my colleague John Hagee
and to come up here to give you a tour
of image capture and a couple special
things we did for you
okay thanks Steve I'm John Maggie a lot
of image capture engineers and I'm gonna
give you a demo of how image capture
works kind of from a user standpoint
there you go just this one turned on
okay I'm gonna give you a demo of how
huge capture works from user standpoint
and then sort of along the way show you
where as a developer you can write
applications that fit in it kind of one
of two different places so which capture
is all about connecting devices so I've
got a camera here and I'm going to put
it in PC connect mode and plug it in
so you see the image capture app
launched by itself here and like Steve
was saying the reason it did that is
because of the it's set to open image
capture application on the hot-plug when
it's plugged in so you can think of
these hot plug actions as you know what
happens when the camera's connected you
can also think of them as how to select
which files you want to download if you
have application open up then the user
can either download some of them or
download all of them with a UI for
setting preferences download all there's
no UI the app doesn't come up
I guess these a little progress bar with
icons and the file name and the images
are downloaded or none nothing happens
connect the camera nothing happens so so
this so again from a developer
standpoint this app image capture
application you could if you learn her
to write an app that did something that
would take the place of this application
that's kind of the lowest level to to
get in there and do something with the
images you can use the API to get
notifications of when the cameras
connected and then bring up your own UI
that did whatever you wanted to so
that's the first place to kind of slide
it in here so hot-plug actions see up
the top here there's a as far as the
application the we that we did to do
this get a pop up of the different
devices if you had multiple devices you
could pick which one you wanted to
download from download folders on Mac OS
go ahead and show you case you don't
have Mac OS 10 she should and every
users home directory there's a pictures
folder music folder and a movies folder
so that's just there by default and
although it's called image capture you
know some devices also like Steve said
can take pictures or store mp3s so when
the image capture app it'll sort each
file type in the right folder so
pictures go to pictures folder
movies going to movies folder and mp3s
in the music folder so that's what that
radio button means user can also select
some other folder by clicking this
button and picking a different folder
so how plug actions is which files are
download download folders is where they
go and automatic tasks is what you want
to do with the files after they've been
downloaded this is pretty
straightforward it's basically any app
that you can drag files on to him so you
know you could think you could drag an
alias to Photoshop put it in this list
after the images are downloaded they all
open up in Photoshop or you could have
something more complex that was really
designed to open multiple images at the
same time so we shipped a bunch of a
bunch of apps that you can the user can
choose from these are all Apple scripts
that have been saved as applications but
you could put any kind of application
that accepts multiple files being
dragged onto it in this list but for now
I'm going to choose the format 3 by 5
and it's going to build a series of web
pages with images all scale down and
size to fit laid out on a page so you
can print them out so I'm going to
download some and pick which ones I want
to ones I want to print out here there's
two views there's an icon if you like
this and there's a list view that gives
you a little more information probably
in the future it will have more of the
exif data over here but for now just
image and file size so I'm going to pick
four of these here
and actually you know let me open up the
pictures folder
okay just so you can see him show up so
look at the icon file name progress bar
now once they finish downloading it's
going to launch this Apple script
application and the app is going to go
through with each image and figure out
if it's wider than it is tall or taller
than it is wide and then sort it in the
in the various pages generates these web
pages here so you can open this up and
explore you turn off some of these extra
bars here
so you can think of this as being uh
just a sheet of paper I picked four
because you can fit four or three by 5's
on a single sheet of paper if I'd
selected you know six images there'd be
four on this page and then two on
another page so you just print out each
one Explorer is really nice because they
have kind of a nice print preview setup
where you can adjust the settings so you
print at the full size you know turnoff
headers and footers and turn on print
wide pages make sure the printer is
turned on yes nice glossy paper
so I'm using the photo paper so I'm
going to go in here and set that so that
it looks nice photo paper quality and
hit print so that's it now what's really
what's nice about Explorer is that you
know even though on screen it looks like
they're pretty small you know it looks
like 72 dpi when it gets printed out
it'll use the original image data so
you're not limited to 72 dpi it'll use
the full image size when it prints so
you get nice high resolution photos so
that's an example of you know an
application that is designed to work
with multiple files called from the
image capture application and that's the
second place that as a developer you can
write apps that go in that's sort of the
lighter weight you know maybe a little
more user-friendly a cohesive UI for
users is to write an app that deals with
multiple files and have the user make an
alias and put it in that scripts folder
so I'll show you how that works the
scripts folder
is in library image capture scripts now
those called scripts you memo think of
it as you know applications it doesn't
have to be a script it can be any kind
of application and you can add to this
by just making an alias and but an alias
in here I've got this app called add to
database that Verner wrote isn't as an
example of what you might do so I'm
gonna add an alias in the scripts folder
and now when I launch image capture app
it shows up in the pop-up here so I'm
just like that and pick some more images
so see when uh when the camera first
when the app first launches it gets all
the file names first and once they has
all the file names it goes through and
gets all the thumbnails so the
thumbnails are actually it's not having
to get the whole image file and shrink
it down they're actually exif thumbnail
tag inside each image so that's what's
pretty quick to get the thumbnails so
I'm gonna pick some images here whatever
say these eight so again it's gonna
download so what this application does
is it works with a it works with
FileMaker Pro and it adds each file to a
filemaker pro database and it extracts
and puts in the database the exif data
that's in each image and turns out that
all the images all the cameras that
we've used are really great because they
they put this exif data in with the
image file as a user where you might not
even know it's in there because a lot of
apps you know don't really show that
data in there but there's all kinds of
good stuff in there whether the flash
was turned on or not the exposure time
all kinds of really useful information
so this application puts that all in a
database and once you have it in the
database in FileMaker you can use
different layouts to see as much or as
little information as you want you know
here's one a layout that just has the
pretty basic information thumbnail date
you know what kind of camera it came
from the exposure and you know whether
the flash was odd or not there's a
another layout here that shows more
information in a different view there
you go so here's all the exif data that
we extracted and put in this database so
now it's in a database you can sort it
you know you can see sorted by exposure
time and
figure out you know how come this
picture is so blurry well because the
exposure is way along that's why so
that's another example of something you
might want to do so here's the page that
got printed out and of course you can't
see it from back there but it looks
pretty good so a couple of things that
are kind of nice about Mac os10
from an image cache image capture
standpoint is you can change the size of
icons you make icons really big so like
this pictures folder here so I put it in
icon mode open this up and go to view
options say keep range my name okay I
can turn this icon size up pretty high
and then just in the finder you get a
nice preview of what the image looks
like that's pretty convenient and then
the kind of second tip but image capture
is that you can customize the toolbar in
Mac OS 10 do customize toolbar and you
can add let's see where it is pictures
there are you know buttons for your
pictures folder your movies folder and
your music folder so you can add that to
the toolbar and then no matter where you
are by clicking the pictures you can go
right to your pictures folder it's kind
of nice so that was an example of two
applications one of them is a an Apple
script that we ship users can use to
print out through by 5's a second one is
when the burner did that extracts the
exif data listener in a in a filemaker
pro database and select maybe that gives
you an idea of some kind of apps you can
write that that deal with multiple files
so with that all handed over diverter
hello my name is Ronan Northland and I'm
one of the image capture engineers but
now you should have a good idea about
what image capture is and you actually
saw it in action and so let's look at
what year would have to do in order to
use image capture from your application
so first I'm going to talk about the
application level api's that means write
an application that uses image capture
and get some data from a device before
we actually look at the api's just a few
words about the whole idea how to use it
so we have an object based API which
means we are dealing with objects and
properties more than that later Steve
was mentioning we are device independent
that means whether it's a scanner or a
camera scanners in the future cameras
now we support it and we're transport
independent so USB devices firewire
devices and whatever you can think of
when we talk about objects all the icao
objects it's an opaque structure so you
use that as reference whenever you want
to access data data from the camera so
objects they do have types and subtypes
they basically identify the object
objects can contain properties
properties the ica properties that's
where the actual data is stored and
properties as well have types and
subtypes to get identified so the
symbols model is we have one object that
may have another may contain another
object reference another object and a
property we always have a very special
object at the beginning of a tree that's
our device list that's always there even
if you don't have a camera or other
device connected you always have the
device list in this case we are showing
multiple devices so two cameras two
scanners are connected and what will
happen well if we have a closer
at camera 2 you will see we have three
images there and we will have some
properties for the device for example
the name you saw that in the image
capital image capture application we had
the name and an icon so the icon of
course is also a property clock could be
a property we could have a whole bunch
of properties and that's the same thing
for the images so images have properties
like the image data they have a
thumbnail property they have the image
width and height the image name all
these are properties so if you look at
that tree now then you will see in order
to get to the image data
the only direct access point you have is
the device list so from the device list
you have to go to the device from the
device you go to the images and from the
images you go to the image data so
device objects you access those via the
device list the image objects via the
device object and once you have device
object you can iterate over all the the
properties first you get the images and
then iterate over all the properties to
get to the actual image data all our
api's have two functions two parameters
they all take a parameter block and a
callback a completion proc a good idea
to always clear so do a mem set of the
whole parameter clock fill in whatever
you want to pass in to that call make
the call and then depending on whether
you make it a synchronous or
asynchronous extract the data so that's
how the napier looks like so it's an
always starts with an i ca the image
capture architecture and returns an OS
error you pass in a parameter clock and
a completion proc now for the completion
clock that's how you decide how to make
you what whether you want to make your
calls synchronous or asynchronous
if you pass in nil as completion brach
then it's a synchronous call which means
you make the call
the camera will do whatever you tell it
to do comes back and you have that the
result asynchronous calls you specify
your completion prog you do the image
capture you call the image capture API
it immediately returns and then it will
call whenever the data is available from
the device it will call your completion
proc actually that's what we do in the
image capture application so all our
calls are asynchronous so the nice thing
about that is you get a pretty snappy
application so it's it's working the UI
is updating without having the
application to be multi-threaded so it's
a thing of single threaded application
and it still feels like yeah it's
responsive so the completion proc has
the single parameter and that's the ICA
header that you have to typecast to
whatever call result you're expecting
you will have a look at that in a bit so
I will go to show you how to write small
image capture application and then we
will look at that if you look at all our
api's we can Kroop them into more or
less three groups one is we have some
basic functions then we have AP eyes
that deal with objects and then of
course the API has to deal with the
properties to get to the real data so
the basic functions we have very
important accessor and let's get the
device list so remember that was the top
of the tree that's the only device
that's always there even if there's no
camera connected and then we have an
object
send message that's very useful whenever
you want to send a message to for
example the device like take a picture
you can also send messages to image
objects like delete this image object
and of course what you want to do and
you saw that you would see it whenever
you look at the image capture
application if you launch the
application and no device is connected
then you connect the device then it
updates automatically to the UI
and that's done by using the ica
register event notification so you get
notification once you register to that
whenever device is connected or
disconnected so once again the device
list the ICU get device list gives you
the object for the device list and you
can send a message to like a device take
picture the object related functions
well it's quite clear when nervous look
at the advice object tree you have to
walk through the tree and that's
basically what the device but the object
related functions do so you want to find
out how many children do you have for a
given object so if you look at the
device list in that case it would return
it to meaning we have two devices
connected for this second device index
one so we start current with zero index
one we would get back in a child count
of three meaning we have three objects
three images in that case as I said
before each object has a type and
subtype and we can get to that using the
get object info so the type for the
first one would be the device that's the
device list and then we have the device
camera device scanner and all those and
for the images or sound files we would
have identifier saying well it's an
image it's an audio it's a it's a movie
if we want to get to a specific object
like in that case we already captured
the device and you want to get to the
second image well first of all it's a
good idea to do it get a child count
find out how many images to be have and
if you want to iterate over all those
then we would here is to get in child
okay tenth child takes an index and
returns you an object reference once you
have an object you can always get to the
top of the tree to the device list using
the get device list call or you could
get to the top of the device specific
objects by using the get route of object
that will always give you the camera
device your parent of object might be
useful if you have a directory structure
which we're currently not supporting in
our UI currently everything is flattened
out also the PDP and class one drivers
currently flatten out everything but in
theory you could have like a directory
object and all those children can access
the directory object by using the get
parent of object we have reference that
you can set and get and then we have a
whole bunch of setters and getters for
properties so same deal if we have an
object and we want to get the number of
properties let me just do an ICA get
property count that returns us the
number of properties and to access the
property you could do that on two ways
one way would be you can iterate over
all the properties so get in object as
in 0 1 and so on
or if you know exactly what you're
looking for like in this case you could
just look for the image width and
instead of now looping over all
properties you would just do a get
property by type and pass in image width
as the OS type that you're looking for
you can get information about properties
using get property info and you can get
and set the property data in megawatts
10 1000 the set property data is not
implemented but we will do that in the
future so you will be able to modify
properties like upload images or sound
files get property get property data
this call is basically the the way to
get to the actual
image data or thumbnail data or whatever
you have stored in properties then in
order to navigate around a bit again
there's a get route of property which
give you the device object and get pound
of property that's the object that
contains this property setters and
getters for ref cons and now let me just
switch over to the demo machine and I
will show you a small application that
we have to browse the property
information so we have an application
called
image capture browser and what it does
is just looking for devices objects
properties in this case I was doing the
get device list and then get the number
of objects for that device list well we
have only one so it's one camera
connected so I select that camera and
then you see all information flows in
now this is again an example of writing
it in an asynchronous mode so as you you
saw just clicking on it it's really
updates the UI immediately and the data
that's not available just flows in
whenever it gets available so that's
that's the camera that John was using so
with all the images again for example
get the volume label so it's an HP
photosmart the T is missing let's back
in in the 100 versions where you have to
pass in but never get to the volume
label not the actual length that you
have to have to increment it by one in
order to get the determination so you
can get the camera icon so it shows you
number of bytes you can click on an
image and then it will display well we
have currently four properties that's
the image data a thumbnail file name and
file size so if I click on the file name
so I would get the the name 13 bytes for
that property thumbnail
image data when you see this one is 145
K in size so you can just use that app
to find out what's inside the camera and
just look at it look at the data so now
I'm just switching over to the project
builder and what I am trying to do now
is show you how easy it is to write an
application that uses image capture so
we start from scratch and we look
actually I have a small application
already prepared and you'll see it's
almost from scratch so I switch over to
the resources so it's a small cocoa
application and I mean all it has is the
main and then let's go to the interface
builder and then well you see everything
is just empty and I could now start
switching over and adding an asymmetry
you to do that and because what this
small application should do is just
capture some hits from the camera well I
could do that but what I also could do
is I can go to preferences and actually
use the palette and that's the I see a
view palette so you'll see that and all
I do is I track that over I save the app
I didn't change anything in here and now
let's see what happens if we run this
it launches and it shows the sample well
actually it does more so it has a slider
and we can now go through all the images
that are in the device and that was
without writing a lot single line of
code well not quite
well another thing that can do this like
it allows you to track the image so
whenever you are in mail you can just
drag that over to mail and then insert
it there so let's quit this one and
let's see where the magic really lies if
we go to the classes we see there's an I
see a view that agent M now actually if
you look at the documentation for
interface builder and how to write image
interface builder palettes it tells you
that there are three ways to actually
include the code one is in your project
you just have this sources that's what I
do the other one would be you just use
the the pre compiled files and got all
files and add those or create a small
framework and use that well in this case
since I want to show you how this this
view actually works I was including the
sources so let's go to this one and have
a look at the sources
if we do awake from nib that's the call
actually that you will get whenever your
application is launched when the nib
file is loaded what I'm doing here
that's a tricky thing yes I want to work
or make make it work that this view
actually only works in your application
and not in the interface builder part so
what I'm doing is if the application
does not respond to one selector that I
know that interface builder is using so
the interface builder then I'm actually
initializing the view and initializing
the view is actually very simple because
all I do is all I do is I call register
event notification I want to get
notified when a device is connected and
whenever device is disconnected then oh
that's that's where we are not quite to
the standard so the the the best way
would actually be to get the thumbnail
for the thumbnail data get the size of
the property that's something in the
property info so you would know how big
of thumbnail do I really have in that
camera well in this case I know it's 128
by 128 so I'm cheating a bit and then
after allocating this buffer I'm doing a
rescan for devices but so let's look at
it the the first part which is the event
notification so what we do so we haven't
I see a virtual event notification
parameter Plock and as I told you the
good idea to do a memset first so
cleared out and then I set the refcon
for the header to the self well in this
case it's not needed because as you can
see down here on the call itself I'm
doing a synchronous call so refcon might
be nice but not needed
I pass in as object null which means for
the event notification means notify me
on all object changes so I'm not
interested in a specific object at all
and then the notified type that got
passed in which was the device added or
device removed so under just make the
call and that's it now the rescan here
so last thing we did in our
initialization was rescan for devices
risk and for devices is also pretty
straightforward what it does well first
if we never got initialized so remember
I did not have a single line of code
that I created for that project it was
outside the view definition so I did not
initialize the view did not do anything
so what I have to do is now I have the
image view that's in this nib file
connected to the slider and that's what
I'm doing here and then if we never did
get the device list before actually then
I will get it and just keep reference to
it so getting the device list again I
have a parameter plot that I clear and
then I call get device list and do that
again in a synchronous way so passing
now as a completion proc so the device
list will be set inside this get device
list parameter block now if we did get a
device list what I want to do is I want
to find out how many devices are
connected so I would just go ahead and
pass in as the object that I'm
interested in how many children's do you
have that's the device list in that case
so pass that in get shot count if the
child can't is zero so we have no
cameras connected then I just call my no
device found which would just dim the
slider and bring up a generic icon get
in child well what I do is I want to get
the first camera so this very simple app
just looks at the first camera in
negative zero and then tries to get the
the device so if we did get the device
actually first so if we have no device
let me just take a predefined tip file
I see a image view TIFF and just play
that inside our and it's you so if we
did get the if we did get a device then
what we have to do is find out how many
images do we have so again we have a get
child count parameter clock and we clear
it we set the object we are interested
in to the first device and then we just
call get child count so how many images
or movie files do we have we get the
number back save that in