1
我有佳能EOS D600相機。需要使用C++拍攝照片。文檔沒有幫助我。您是否有示例代碼,需要拍照?這並沒有幫助:Canon SDK。從相機拍照
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <EDSDK.h>
#include <EDSDKTypes.h>
#include <EDSDKErrors.h>
using namespace std;
EdsError getFirstCamera(EdsCameraRef *camera);
int main(){
EdsError err=EDS_ERR_OK;
EdsCameraRef camera=NULL;
bool isSDKloaded=false;
err=EdsInitializeSDK();
if(err==EDS_ERR_OK) isSDKloaded=true;
if(err==EDS_ERR_OK) err=getFirstCamera(&camera);
EdsOpenSession(camera);
EdsInt32 saveTarget = kEdsSaveTo_Host;
err = EdsSetPropertyData(camera, kEdsPropID_SaveTo, 0, 4, &saveTarget);
EdsCapacity newCapacity = {0x7FFFFFFF, 0x1000, 1};
err = EdsSetCapacity(camera, newCapacity);
const char* ch_dest = "C:\\photo\\Img.jpg";
EdsCreateFileStream(ch_dest ,kEdsFileCreateDisposition_CreateAlways,kEdsAccess_ReadWrite,0);
EdsSendCommand(camera, kEdsCameraCommand_TakePicture, 0);
EdsCloseSession(camera);
EdsTerminateSDK();
return 0;
}
EdsError getFirstCamera(EdsCameraRef *camera)
{
EdsError err=EDS_ERR_OK;
EdsCameraListRef cameraList=NULL;
EdsUInt32 count=0;
// Get camera list
err = EdsGetCameraList(&cameraList);
// Get number of cameras
if(err == EDS_ERR_OK)
{
err = EdsGetChildCount(cameraList, &count);
if(count == 0)
{
err = EDS_ERR_DEVICE_NOT_FOUND;
}
}
// Get first camera retrieved
if(err == EDS_ERR_OK)
{
err = EdsGetChildAtIndex(cameraList , 0 , camera);
}
// Release camera list
if(cameraList != NULL)
{EdsRelease(cameraList);
cameraList = NULL;
}
return err;
}
#include <windows.h>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <EDSDK.h>
#include <EDSDKTypes.h>
#include <EDSDKErrors.h>
using namespace std;
EdsError getFirstCamera(EdsCameraRef *camera);
int main(){
EdsError err=EDS_ERR_OK;
EdsCameraRef camera=NULL;
bool isSDKloaded=false;
err=EdsInitializeSDK();
if(err==EDS_ERR_OK) isSDKloaded=true;
if(err==EDS_ERR_OK) err=getFirstCamera(&camera);
EdsOpenSession(camera);
EdsInt32 saveTarget = kEdsSaveTo_Host;
err = EdsSetPropertyData(camera, kEdsPropID_SaveTo, 0, 4, &saveTarget);
EdsCapacity newCapacity = {0x7FFFFFFF, 0x1000, 1};
err = EdsSetCapacity(camera, newCapacity);
const char* ch_dest = "C:\\photo\\Img.jpg";
EdsCreateFileStream(ch_dest ,kEdsFileCreateDisposition_CreateAlways,kEdsAccess_ReadWrite,0);
EdsSendCommand(camera, kEdsCameraCommand_TakePicture, 0);
EdsCloseSession(camera);
EdsTerminateSDK();
return 0;
}
EdsError getFirstCamera(EdsCameraRef *camera)
{
EdsError err=EDS_ERR_OK;
EdsCameraListRef cameraList=NULL;
EdsUInt32 count=0;
// Get camera list
err = EdsGetCameraList(&cameraList);
// Get number of cameras
if(err == EDS_ERR_OK)
{
err = EdsGetChildCount(cameraList, &count);
if(count == 0)
{
err = EDS_ERR_DEVICE_NOT_FOUND;
}
}
// Get first camera retrieved
if(err == EDS_ERR_OK)
{
err = EdsGetChildAtIndex(cameraList , 0 , camera);
}
// Release camera list
if(cameraList != NULL)
{EdsRelease(cameraList);
cameraList = NULL;
}
return err;
}
有錯誤: [鏈接錯誤]未定義參考`小鬼 _EdsInitializeSDK @ 0'
請幫助
java在哪裏呢? –
您鏈接到Canon EOS SDK嗎? – Chris
問題不在於代碼,而在於你需要在庫中進行鏈接。你如何做到這一點取決於你的操作系統和環境。 – dutt