佳能SDK图像处理示例 [英] Canon SDK example for image processing
问题描述
我想在c#或VB.NET程序中使用佳能EDSDK来查看cr2文件.
I would like to use the canon EDSDK in a c# or VB.NET program, to view cr2 files.
我找到了有关如何控制相机的示例代码-示例:
I have found sample code on how to control the camera - example:
https://github.com/esskar/Canon.Eos.Framework
但是与打开文件,提取图像数据并显示它无关,也没有将拇指或全尺寸图像另存为jpg ...
but nothing about opening the files, extracting the image data and displaying it - or saving the thumbs or full sized image as a jpg...
有人可以指导我介绍一些这样的例子吗?谢谢.
Could someone direct me to some such examples ? Thank you.
注意-我有EDSDK 2.12,希望较早的版本也能提供帮助.
Note - I have EDSDK 2.12, i hope older versions could also help.
谢谢您的建议,它指向一个可能有用的C库...虽然我不知道如何,但不确定如何在点网中使用它.
Thank you for the suggestion, it points to a C library that may help... Though I don't know how, not sure how i can use it in dot net.
推荐答案
我知道距问这个问题已经有一段时间了,但它仍然可能对某人有所帮助.要使用SDK处理佳能原始文件,您必须执行以下操作:
I know it's been a while since this question has been asked, still it might help someone. To process canon raw files with the SDK you have to do this:
uint err;
//Create input stream
IntPtr inStream;
err = EDSDK.EdsCreateFileStream("Test.CR2", EDSDK.EdsFileCreateDisposition.OpenExisting, EDSDK.EdsAccess.Read, out inStream);
//Create image reference
IntPtr imgRef;
err = EDSDK.EdsCreateImageRef(inStream, out imgRef);
//Set properties
err = EDSDK.EdsSetPropertyData(imgRef, EDSDK.PropID_WhiteBalance, 0, 4, EDSDK.WhiteBalance_Cloudy);
//TODO: set any imageRef compatible property you need here.
//Create output stream
IntPtr outStream;
err = EDSDK.EdsCreateFileStream("TestOut.jpg", EDSDK.EdsFileCreateDisposition.CreateAlways, EDSDK.EdsAccess.Write, out outStream);
//Get image info
EDSDK.EdsImageInfo info;
err = EDSDK.EdsGetImageInfo(imgRef, EDSDK.EdsImageSource.FullView, out info);
//Set image settings
EDSDK.EdsSaveImageSetting set = new EDSDK.EdsSaveImageSetting();
set.JPEGQuality = 9;
//Save image
err = EDSDK.EdsSaveImage(imgRef, EDSDK.EdsTargetImageType.Jpeg, set, outStream);
//Release data
EDSDK.EdsRelease(imgRef);
EDSDK.EdsRelease(inStream);
EDSDK.EdsRelease(outStream);
当然,您不必从HD读取文件,但也可以使用从摄像机获得的图像参考.
Of course you don't have to read a file from the HD but can also use an image reference you got from the camera.
在没有SDK的情况下获取预览图像的另一种方法是读取CR2本身.它基本上只是一个Tiff文件,它存储一个jpg缩略图(160x120)和两个更大的RGB图像.该网站在此提供了有关整个CR2格式的一些良好信息: http://lclevy.free.fr/cr2/
Another way to get preview images without the SDK would be to read out the CR2 itself. It is basically just a Tiff file and it stores a jpg thumbnail (160x120) and two a bit bigger RGB images. This website here provides some good information about the whole CR2 format: http://lclevy.free.fr/cr2/
亲切的问候
这篇关于佳能SDK图像处理示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!