我试图为我的佳能EOS Rebel T7创建一个程序,但是当我试图发送命令EDSDK.EdsSendCommand(CamConn,EDSDK.CameraCommand_TakePicture,0)时,该程序返回错误EDS_ERR_INVALID_HANDLE,我如何添加一个正确的句柄来获取选择?谢谢!这里的代码打印
发布于 2020-03-25 00:54:36
首先,欢迎来到StackOverflow。
未来的提示:将代码复制/粘贴到你的问题中,不要链接到图片。对每个人来说,阅读都更容易,也许可以自己抄袭来尝试。
现在请回答你的问题:
CamConn句柄来自哪里?很可能OpenConnection调用已经返回无效句柄错误。
要获得有效的相机手柄,您必须执行以下操作:
public IntPtr[] GetConnectedCameraPointers()
{
// get a list of connected cameras
EDSDK.EdsGetCameraList(out IntPtr cameraList);
// get the number of entries in that list
EDSDK.EdsGetChildCount(cameraList, out int cameraCount);
// create an array for the camera pointers and iterate through the list
var cameras = new IntPtr[cameraCount];
for (int i = 0; i < cameraCount; i++)
{
// gets an item of the list at the specified index
EDSDK.EdsGetChildAtIndex(cameraList, i, out IntPtr cameraPtr);
// get a device info for that camera, this is optional but may interesting to have
EDSDK.EdsGetDeviceInfo(cameraPtr, out EdsDeviceInfo cameraInfo);
// store the camera pointer in our array
cameras[i] = cameraPtr;
}
// release the camera list
EDSDK.EdsRelease(cameraList);
return cameras;
}请注意,为了简单起见,我没有检查返回的错误代码,但是您应该明确地检查它们。
https://stackoverflow.com/questions/60839703
复制相似问题