gpt4 book ai didi

c# - 使用 EDSDK 2.9 从佳能相机中检索图片

转载 作者:太空宇宙 更新时间:2023-11-03 14:25:08 26 4
gpt4 key购买 nike

很长一段时间以来,我一直在尝试检索用相机拍摄的图像。我可以使用 SDK 拍照:

err = EDSDK.EdsSendCommand(cameraDev, EDSDK.CameraCommand_TakePicture, 0);

我在打开有效的相机 session 后执行此操作。我还添加了一个

objectEventHandler 和事件的 stateEventHandler,如下所示:

    public static uint stateEventHandler(uint inEvent, uint inParameter, IntPtr inContext)
{
switch (inEvent)
{
case EDSDK.StateEvent_JobStatusChanged:
Debug.WriteLine(String.Format("There are objects waiting to be transferred. Job status {0}", inParameter));
break;

case EDSDK.StateEvent_ShutDownTimerUpdate:
if (inParameter != 0)
Debug.WriteLine(String.Format("shutdown timer update: {0}", inParameter));
break;

default:
Debug.WriteLine(String.Format("StateEventHandler: event {0}, parameter {1}", inEvent, inParameter));
break;
}
return 0;
}

    public static uint objectEventHandler(uint inEvent, IntPtr inRef, IntPtr inContext)
{
switch (inEvent)
{
case EDSDK.ObjectEvent_VolumeInfoChanged:
Debug.WriteLine("volume info changed");

#region retrieve volume info

EDSDK.EdsVolumeInfo volumeInfo;
err = EDSDK.EdsGetVolumeInfo(inRef, out volumeInfo);
if (err == EDSDK.EDS_ERR_OK)
{
switch (volumeInfo.StorageType)
{
case (uint)EDSDK.EdsStorageType.Non:
Debug.WriteLine("No card inserted");
break;
default:
case (uint)EDSDK.EdsStorageType.CF:
case (uint)EDSDK.EdsStorageType.SD:
if (volumeInfo.Access == (uint)EDSDK.EdsAccess.ReadWrite)
{
Debug.WriteLine(String.Format("Label: {0}, Max Capacity: {1}, Free Space: {2}",
volumeInfo.szVolumeLabel, volumeInfo.MaxCapacity, volumeInfo.FreeSpaceInBytes));

/*
err = EDSDK.EdsGetChildAtIndex(volumeInfo, 0, directoryList);
if (err != EDSDK.EDS_ERR_OK)
throw new Exception(String.Format("EdsGetChildAtIndex: " + err.ToString()));
*/
}
else
Debug.WriteLine(String.Format("Volume access rights: {0}", volumeInfo.Access));
break;
}
}

#endregion retrieve volume info

break;

case EDSDK.ObjectEvent_DirItemCreated:
downloadImage(inContext);
Debug.WriteLine("dir item created");
break;

default:
Debug.WriteLine(String.Format("ObjectEventHandler: event {0}", inEvent));
break;
}
return 0;
}

我尝试了多种方法(以检索此图像),但似乎都不起作用。一些方法是:

http://tech.groups.yahoo.com/group/CanonSDK/message/1575

[http://stackoverflow.com/questions/3762530/take-picture-and-directly-save-image-to-pc-using-edsdk-2-8]

[http://canonsdk.com/phpBB3/viewtopic.php?f=7&t=94&sid=7fcbe7ad6eadb399dbcb4b61a7333112]

问题是所有这些都只是代码的一部分,当我尝试将其放入我的代码时,它永远不起作用properly.Properly 因为我不是 memoryStreams 的专家,所以指针。我得到的大多数错误是在读取流并将它们复制到本地缓冲区时,它说流是空的。

有没有人有完整的示例代码来拍照并将其下载到磁盘(或内存),或者我需要的正确方法来完成这个?

谢谢费尔南多

最佳答案

您的代码中的错误是:

downloadImage(inContext);

应该是

 downloadImage(inRef);

关于c# - 使用 EDSDK 2.9 从佳能相机中检索图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4310814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com