Lab. of Voynich Code
2023年オーストラリア・インドネシア    金環皆既日食のたくらみ
光球面とコロナの明るさの比用システム
UMPCを使った制御:要素2
2020.11.23: Open

Nikon SDK C# Wrapperを使ったお助けアプリ

 プログラムの中身
  • ダーク画像用に単純にISO400にて1/3000秒~1/2秒、1.5EV間隔8段の撮像を行う
 たったこれだけ!!

プログラムの設定方法…しかし自己責任にて!!

 Nikon SDK C# Wrapperはココからダウンロードしました。
 demo_continuouscaptureのソースを開き、私の書いたプログラムを貼り付けます。
 私の書いたプログラムはココからダウンロード可能です。
 うまくコンパイル出来たら、ニコンZ6のSDKからNkdPTP.dll, Type0024.md3をEXEファイルと同じフォルダに入れます。
 カメラのシャッター速度・ISO感度は1/2EVステップに設定します。
 後はNikon Z6をPCとUSB接続して.exeファイルをダブルクリックで動くかどうかをチェックします。

 ちなみに私はどうやら手にしたZ6に不良でもあったらしく、そこをSDKが直撃したか、スイッチオフでもバッテリが2日程でなくなるという不具合に見舞われました。幸い保証期間中だったのでメイン基板交換が無料でした。
 そんな訳で、このプログラム・Wrapper・SDKでカメラを破壊し、或いは多大な損失を被っても当局は感知しない。健闘を祈る

   1:  //
   2:  // This work is licensed under a Creative Commons Attribution 3.0 Unported License.
   3:  // Thomas Dideriksen (thomas@dideriksen.com)
   4:  //
   5:  // Modified by M_shi@Lab. of Eclips Manuscript
   6:  // http://horukeu.web.fc2.com/Exp/2023Trial/Index.html
   7:  //
   8:  //
   9:  //
  10:   
  11:  using System;
  12:  using System.Collections.Generic;
  13:  using System.Linq;
  14:  using System.Text;
  15:  using System.Threading;
  16:  using System.IO;
  17:  using Nikon;
  18:   
  19:  //
  20:  // ISO400 1/3000-1/2sec 1.5EV間隔でダーク画像を撮影するプログラムです
  21:  //
  22:   
  23:  namespace Capture_Dark
  24:  {
  25:      class CaptureDark8
  26:      {
  27:          int _captureCount = 0;
  28:   
  29:          NikonDevice _device;
  30:          AutoResetEvent _waitForDevice = new AutoResetEvent(false);
  31:          AutoResetEvent _waitForCaptureComplete = new AutoResetEvent(false);
  32:   
  33:          public void Run()
  34:          {
  35:              try
  36:              {
  37:                  // Create manager object - make sure you have the correct MD3 file for your Nikon DSLR
  38:                  //Type00##.md3の##が機種によって違う
  39:                  NikonManager manager = new NikonManager("Type0024.md3");
  40:   
  41:                  // Listen for the 'DeviceAdded' event
  42:                  manager.DeviceAdded += manager_DeviceAdded;
  43:   
  44:                  // Wait for a device to arrive
  45:                  _waitForDevice.WaitOne();
  46:                  
  47:                  //多段階AEブラケティング
  48:                  _ = AEBlacket_Capture( );
  49:   
  50:   
  51:                  // Shutdown
  52:                  manager.Shutdown();
  53:              }
  54:              catch (NikonException ex)
  55:              {
  56:                  Console.WriteLine(ex.Message);
  57:              }
  58:          }
  59:   
  60:          //多段階AEブラケティング撮像
  61:          public int AEBlacket_Capture()
  62:          {
  63:              // Set shooting mode to 'continuous, highspeed'
  64:              NikonEnum shootingMode = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode);
  65:              shootingMode.Index = (int)eNkMAIDShootingMode.kNkMAIDShootingMode_CH;
  66:              _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShootingMode, shootingMode);
  67:   
  68:              //Set Sesitivity 400
  69:              NikonEnum ISOSens = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_Sensitivity);
  70:              ISOSens.Index = 6;
  71:              _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_Sensitivity, ISOSens);
  72:   
  73:              int i = 0;
  74:              NikonEnum SpeedMode = _device.GetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed);
  75:   
  76:                  // SS 1/3000 - 1/2sec, 1.5EV step, 8段で多段階撮像する
  77:                  for (i = 36; i >= 15; i = i - 3)
  78:                  {
  79:                      SpeedMode.Index = i;
  80:                      _device.SetEnum(eNkMAIDCapability.kNkMAIDCapability_ShutterSpeed, SpeedMode);
  81:   
  82:                      // Set number of continuous captures - in this case we want 1
  83:                      _device.SetUnsigned(eNkMAIDCapability.kNkMAIDCapability_ContinuousShootingNum, 1);
  84:   
  85:                      // Hook up capture events
  86:                      _device.ImageReady += _device_ImageReady;
  87:                      _device.CaptureComplete += _device_CaptureComplete;
  88:   
  89:                      // Capture
  90:                      _device.Capture();
  91:   
  92:                      // Wait for the capture to complete
  93:                      _waitForCaptureComplete.WaitOne();
  94:   
  95:                      // 時間調整
  96:                      System.Threading.Thread.Sleep(250);
  97:                  }
  98:   
  99:              return 0;
 100:          }
 101:   
 102:   
 103:          void _device_ImageReady(NikonDevice sender, NikonImage image)
 104:          {
 105:              // Save captured image to disk
 106:              string filename = "image" + _captureCount.ToString() + ((image.Type == NikonImageType.Jpeg) ? ".jpg" : ".nef");
 107:              _captureCount++;
 108:   
 109:              using (FileStream s = new FileStream(filename, FileMode.Create, FileAccess.Write))
 110:              {
 111:                  s.Write(image.Buffer, 0, image.Buffer.Length);
 112:              }
 113:          }
 114:   
 115:          void _device_CaptureComplete(NikonDevice sender, int data)
 116:          {
 117:              // Signal the the capture completed
 118:              _waitForCaptureComplete.Set();
 119:          }
 120:   
 121:          void manager_DeviceAdded(NikonManager sender, NikonDevice device)
 122:          {
 123:              if (_device == null)
 124:              {
 125:                  // Save device
 126:                  _device = device;
 127:   
 128:                  // Signal that we got a device
 129:                  _waitForDevice.Set();
 130:              }
 131:          }
 132:      }
 133:   
 134:      class Program
 135:      {
 136:          static void Main(string[] args)
 137:          {
 138:              CaptureDark8 demo = new CaptureDark8();
 139:              demo.Run();
 140:          }
 141:      }
 142:  }


    
inserted by FC2 system