简体   繁体   中英

How to control a camera with Delphi

A Delphi programm should make produkt photos with a Nikon D5000AF SDX. The only commands I need are "make a photo", "get me the photo".

Which library or API can help me?

@Heinz, to control a device you must use an SDK, which must be supplied by the manufacturer of the device.

from the nikon site :

....We are offering Library Programs and Command API Specifications for software applications that offer remote control functions for Nikon digital-SLR cameras connected to a computer. When these are utilized, the software application can be used to modify camera settings, including shutter speed, aperture, and ISO sensitivity, and to control camera operations, including shutter release.

in this page you can find the SDK for the Nikon cameras, including the D5000 series.

Bye.

I would advise using the WIA (Windows Image Acquisition) API. For this you need the file "WIALib_TLB.pas" which will be created by Delphi automatically when following these steps:

  1. Select "Project > Import Type Library" from the Menu
  2. Select ""Microsoft Windows Image Acquisition 1.01 Type Library" from the list
  3. Choose "Create Unit"
  4. You will then get the unit "WIALib_TLB.pas", which by default stored in C:\Users\<username>\Documents\RAD Studio\5.0\Imports , which will need to be added to your library search path if it isn't already there.

Use the code from the following URL to see how you can enumerate the available devices and their properties and take a snapshot with the camera.

http://www.neunbeere.de/UseNet/WIA.html

Sorry, the comments are in German, but I think the code is easy to understand

  • you can use wia (windows image acquisition)
  • from component menu select import component and select windows image acquisition and install it
  • or download and add to your project
  • then
  • if you are use win xp
  • start new project and put
  • new Button named Button1
  • new CheckBox named MultiPic
  • and copy the cod and past in Button1

the cod:

procedure TForm1.Button1Click(Sender: TObject);
var
   wia:IWia;
   WiaInf: IWiaDeviceInfo;
   wiaImg: IWiaDispatchItem;
   I:integer;
   Coll: ICollection;
begin
  wia:=CoWia.Create;
  WiaInf:= WIA.Devices.Item[0] as IWiaDeviceInfo;
  wiaImg:=WiaInf.Create;
  if MultiPic.Checked then
  begin
    coll:=wiaImg.GetItemsFromUI(UseCommonUI, MaximizeQuality);
    for I := 0 to coll.Count - 1 do
      begin
        wiaImg:=coll.Item[i]  as IWiaDispatchItem ;
        wiaImg.Transfer('C:\Source\test'+inttostr(i)+'.bmp',false);
      end;
  end
  else
  begin
    wiaImg:=wiaImg.GetItemsFromUI(SingleImage, MaximizeQuality).Item[0]  as IWiaDispatchItem ;
    wiaImg.Transfer('C:\Source\test.bmp',false);
  end;
end;
  • i use CheckBox to for user Determine if he want 1 picture or multi pictures

  • you can load the Picture/s to image by loadfromfile

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM