.Net tips for playing SLR
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, }
api methods for portable devices. Interested students can try
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++; } } }
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);
The first one is used for data processing such as data copying, picture saving, etc.
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
Program controlled camera to take pictures
Load in-camera photo data
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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.

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

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

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

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,

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

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
