C# 佳能(Canon)相机EDSDK应用开发(一)--基本

需求要做个小软件,软件可以控制多个相机进行实时预览拍照.其实大家都知道一般这种开发只要有厂商的SDK就OK了.但听别人说是要用C++...我一听就有点怵..后来一看官方的软件工具就是C#写的(窃笑)

                   大家英文好的话直接看文档了,这里只摘要些重要的部分.

一、与相机工作流程

  1.SDK初始化:EDSDK.EdsInitializeSDK();

  2.与相机建立会话通道:EDSDK.EdsOpenSession(IntPtr camera);

  3.工作处理...

  4.结束与相机的会话:EDSDK.EdsCloseSession(IntPtr camera);

  5.注销SDK:EDSDK.EdsTerminateSDK();

*在应用程序周期中应保持SDK加载,及与相机的会话通道畅通.只在程序结束时注销SDK,或特殊处理时关闭到某个相机的会话通道.

二、API返回

       正常状态均返回‘0’,即EDSDK.EDS_ERR_OK

三、实件处理

  1、事件代理声明
        private event EDSDK.EdsPropertyEventHandler PropertyEventHandler;

 2、回调

        PropertyEventHandler += new EDSDK.EdsPropertyEventHandler(I_PropertyEventHandler);

        void I_PropertyEventHandler(uint inEvent, uint inPropertyID, uint inParam, IntPtr inContext)
        {
            //throw new NotImplementedException();
        }

     3、绑定

     EDSDK.EdsSetObjectEventHandler(camera, EDSDK.ObjectEvent_All, ObjectEventHandler, IntPtr.Zero);

 

四、获取、设置相机属性

   1、获取相机属性:属性都以uint表示,根据获取的值对应文档中的属性说明或获取属性的DESCRIBE

            uint _data;
            EDSDK.EdsDataType _dataType;
            int _dataSize;

            //获取相机当前的存储位置属性(1-相机;2-PC;3-同时)
            _hr = EDSDK.EdsGetPropertySize(camera, Example:EDSDK.PropID_SaveTo, 0, out _dataType, out _dataSize);
            _hr = EDSDK.EdsGetPropertyData(camera, Example:EDSDK.PropID_SaveTo, 0, out _data);
            return _data;

     2、设置相机属性:

        IntPtr _data=new IntPtr(2);

        EDSDK.EdsSetPropertyData(camera, EDSDK.PropID_SaveTo, 0, Marshal.SizeOf(_data), _data);

  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 12
    评论
----------------------------------------------------------------------------------- EDSDK Library README File ----------------------------------------------------------------------------------- This Readme file contains the latest information about the EDSDK Library. Please read this file before using the EDSDK Library. ----------------------------------------------------------------------------------- Contents 1. Acknowledgments 2. Copyrights 1. Acknowledgments ------------------ This software is based in part on the work of the Independent JPEG Group. 2. Copyrights ------------- IJG: Permission is hereby granted to use, copy, modify, and distribute this software (or portions thereof) for any purpose, without fee, subject to these conditions: 1. If any part of the source code for this software is distributed, then this README file must be included, with this copyright and no-warranty notice unaltered; and any additions, deletions, or changes to the original files must be clearly indicated in accompanying documentation. 2. If only executable code is distributed, then the accompanying documentation must state that "this software is based in part on the work of the Independent JPEG Group". 3. Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind. These conditions apply to any software derived from or based on the IJG code, not just to the unmodified library. If you use our work, you ought to acknowledge us. Permission is NOT granted for the use of any IJG author's name or company name in advertising or publicity relating to this software or products derived from it. This software may be referred to only as "the Independent JPEG Group's software". We specifically permit and encourage the use of this software as the basis of commercial products, provided that all warranty or liability claims are assumed by the product vendor.
Canon EDSDK C#是一个可以用来远程控制佳能数码单反相机的强大SDK。它提供了一些相机类和函数,可以帮助开发人员实现与相机的交互。Camera类是一个简单的容器,包含了相机指针和有关相机的一些信息。CameraValues是一个静态类,包含了所有单元ID值以及存储从Av、Tv到ISO字符串值的信息。SDKHandler是一个处理相机SDK函数的类,可以调用takephoto函数来拍照。\[1\]\[2\] 关于Canon EDSDK C#的更多信息和使用教程,你可以参考这篇博客文章:http://blog.csdn.net/zajin/article/details/17021339。这篇文章介绍了如何初始化和终止SDK、打开和关闭摄像头会话、获取连接的相机列表、设置和获取相机设置、获取可用的设置列表、正常拍照和使用闪光灯模式、处理相机事件、将拍摄的照片下载到电脑上等等。请注意,这个SDK是根据GPL许可证发布的,使用时请自行注意风险。\[3\] #### 引用[.reference_title] - *1* *3* [佳能相机操作 EDSDK 教程 C# 版本](https://blog.csdn.net/weixin_30815427/article/details/95392030)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [佳能相机的拍照应用开发canon EDSDK C#](https://blog.csdn.net/u014528558/article/details/48807515)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值