Home Backend Development C#.Net Tutorial .Net tips for playing SLR

.Net tips for playing SLR

Mar 12, 2017 pm 02:04 PM
.net

This article shares the use of .Net to play SLR

Background

I haven’t visited the garden for more than a year. I changed the industry circle and felt that I was too busy. Yes, but it is also rewarding to be exposed to different R&D cultures, such as the technical flow in the gaming circle, the business flow in the e-commerce circle, the artistic flow in the media circle, etc.

The background of this application is to automate SLR cameras. The boss himself wants to do programming for the usb interface, but it is too low-level technology to usec#It’s not very appropriate to do it. After haggling for a while, let’s do it for the SLR.

Assume a scenario where we need N SLR devices to aim at a flower, take a photo every 30 seconds and automatically post it to Weibo.

Technical Points

Canon SDK

WIA Standard

Canon SDK provides dll. NET developers quoted that Canon's corresponding camera models can be easily accessed by calling the SDK, but the .NET version of the SDK does not provide access to the data in the camera. So how to obtain the data in the SLR camera becomes a problem. Some students may be confused. If the SLR camera is connected to the USB port of the computer, a drive letter will be generated. Can't it be enough to directly use DriveInfo.GetDrives() to obtain the drive letter traversal? Let me educate you first. The classification of USB slave devices can be obtained from the bInterfaceClass byte corresponding to the USB device interface descriptor. Typical codes for bInterfaceClass are 1, 2, 3, 6, 7, 8, 9, 10, 11, 255. The respective meanings are 1-audio: indicating an audio device. 2-communication device: communication equipment, such as telephone, moden, etc. 3-HID: Human-computer interaction device, such as keyboard, mouse, etc. 6-image imaging equipment, such as scanners, cameras, etc. Sometimes digital cameras can also be classified into this category. 7-Printer class. Such as one-way, two-way printers, etc. 8-mass storage mass storage class. Everything with certain storage capabilities can be classified into this category. For example, most digital cameras fall into this category. 9-hub class. 11-chip card/smart card. 255-vendor specific. Manufacturer’s custom class, mainly used for some special equipment. Such as interface adapter card, etc.

The device types that our driveinfo can capture are


public enum DriveType
    {
        // Summary:
        //     The type of drive is unknown.
        Unknown = 0,
        //
        // Summary:
        //     The drive does not have a root directory.
        NoRootDirectory = 1,
        //
        // Summary:
        //     The drive is a removable storage device, such as a floppy disk drive or a
        //     USB flash drive.
        Removable = 2,
        //
        // Summary:
        //     The drive is a fixed disk.
        Fixed = 3,
        //
        // Summary:
        //     The drive is a network drive.
        Network = 4,
        //
        // Summary:
        //     The drive is an optical disc device, such as a CD or DVD-ROM.
        CDRom = 5,
        //
        // Summary:
        //     The drive is a RAM disk.
        Ram = 6,
    }
Copy after login


## Generally, USB disk devices are Removable, but SLR cameras are PortableDevices, and this type cannot be obtained using the GetDrives method. Windows systems32 provides a series of

api methods for portable devices. Interested students can try

.Net 玩单反的技巧

Here I choose wia interface programming. WIA is the abbreviation of Windows Image Acquisition. The currently available version is WIA 1.0, which is a digital image acquisition service provided in Windows Millennium Edition (Windows Me) or higher versions of Windows systems. It can also be used For managing digital imaging equipment. WIA is a COM component implemented using out-of-process services. Unlike most out-of-process service programs, WIA avoids performance loss during image data transfer by providing its own data transfer mechanism (IWiaDataTransfer interface). . The high-performance IWiaDataTransfer interface uses shared memory to transfer data to client programs.

WIA has three main components: Device Manager, Minidriver Service Library and Device Minidriver. ◆Device Manager: Enumerate image devices, obtain device attributes, create events
and create device
objects for the device; ◆Minidriver Service Library: Execute all device-independent functions Service; ◆Device Minidriver Explanation Mapping: WIA Attributes
and commands to specific devices.
Through the information in DeviceManagerClass().DeviceInfos, we can collect the device information belonging to CameraDeviceType in the SLR. As for
video and other types, there are other similar methods.

        public void DownJpgFromAllCamera()
        {
            int i = 1;
            foreach (IDeviceInfo DevInfo in new DeviceManagerClass().DeviceInfos)
            {
                if (DevInfo.Type == WiaDeviceType.CameraDeviceType)
                {
                    string DeviceID = DevInfo.DeviceID;
                    Device wDevice = DevInfo.Connect();
                    Devparam dev = new Devparam {wiaDevice=wDevice, DeviceID = DeviceID, index = i };
                    new Thread((Camera) => 
                        {
                            DownJpg(((Devparam)Camera).wiaDevice, ((Devparam)Camera).DeviceID, ((Devparam)Camera).index);
                        }
                        ).Start(dev);
                 
                  
                    i++;
                }
            }
        }
Copy after login


Let’s talk about the SDK. Canon sdk .net version provides 5 types of handle delegation

        public delegate uint EdsProgressCallback( uint inPercent, IntPtr inContext, ref bool outCancel);
        public delegate uint EdsCameraAddedHandler(IntPtr inContext);
        public delegate uint EdsPropertyEventHandler(uint inEvent, uint inPropertyId, uint inParam, IntPtr inContext); 
        public delegate uint EdsObjectEventHandler( uint inEvent, IntPtr inRef, IntPtr inContext); 
        public delegate uint EdsStateEventHandler( uint inEvent, uint inParameter, IntPtr inContext);
Copy after login


The first one is used for data processing such as data copying, picture saving, etc.

Second for PC to discover new camera devices

The third one is used for notification of changes in the status of attributes such as data streams in the camera, such as a series of changes caused by taking pictures

The fourth one is used for file operations such as file creation, deletion, etc.

The fifth one is used for the status time of the camera itself, such as abnormal power on and off, etc.

Please refer to the demo program for various application scenarios. Although the load method turns on multi-threading, the hard disk IO itself is serial. Here is just It says that you don’t need to take it seriously

Rendering

Newly added camera equipment

.Net 玩单反的技巧

Program controlled camera to take pictures

.Net 玩单反的技巧

Load in-camera photo data

.Net 玩单反的技巧


The above is the detailed content of .Net tips for playing SLR. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the alternatives to NULL in C language What are the alternatives to NULL in C language Mar 03, 2025 pm 05:37 PM

This article explores the challenges of NULL pointer dereferences in C. It argues that the problem isn't NULL itself, but its misuse. The article details best practices for preventing dereferences, including pre-dereference checks, pointer initiali

How to add next-level C compiler How to add next-level C compiler Mar 03, 2025 pm 05:44 PM

This article explains how to create newline characters in C using the \n escape sequence within printf and puts functions. It details the functionality and provides code examples demonstrating its use for line breaks in output.

Which C language compiler is better? Which C language compiler is better? Mar 03, 2025 pm 05:39 PM

This article guides beginners on choosing a C compiler. It argues that GCC, due to its ease of use, wide availability, and extensive resources, is best for beginners. However, it also compares GCC, Clang, MSVC, and TCC, highlighting their differenc

Is NULL still important in modern programming in C language? Is NULL still important in modern programming in C language? Mar 03, 2025 pm 05:35 PM

This article emphasizes the continued importance of NULL in modern C programming. Despite advancements, NULL remains crucial for explicit pointer management, preventing segmentation faults by marking the absence of a valid memory address. Best prac

What are the web versions of C language compilers? What are the web versions of C language compilers? Mar 03, 2025 pm 05:42 PM

This article reviews online C compilers for beginners, focusing on ease of use and debugging capabilities. OnlineGDB and Repl.it are highlighted for their user-friendly interfaces and helpful debugging tools. Other options like Programiz and Compil

C language online programming website C language compiler official website summary C language online programming website C language compiler official website summary Mar 03, 2025 pm 05:41 PM

This article compares online C programming platforms, highlighting differences in features like debugging tools, IDE functionality, standard compliance, and memory/execution limits. It argues that the "best" platform depends on user needs,

Method of copying code by C language compiler Method of copying code by C language compiler Mar 03, 2025 pm 05:43 PM

This article discusses efficient code copying in C IDEs. It emphasizes that copying is an IDE function, not a compiler feature, and details strategies for improved efficiency, including using IDE selection tools, code folding, search/replace, templa

How to solve the problem of not popping up the output window by the C language compiler How to solve the problem of not popping up the output window by the C language compiler Mar 03, 2025 pm 05:40 PM

This article troubleshoots missing output windows in C program compilation. It examines causes like failing to run the executable, program errors, incorrect compiler settings, background processes, and rapid program termination. Solutions involve ch

See all articles