Programim dhe zhvillim, javascript, python, php, html

Canon SDK. Bëni foto nga kamera

Kam kamerën Canon EOS D600. Duhet të bëni fotografi duke përdorur C++. Dokumentacioni nuk më ndihmoi. A keni një kod shembull që bën një foto? Kjo nuk ndihmon:

#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;
}

Ka gabime: [Gabim lidhës] referencë e padefinuar për "imp_EdsInitializeSDK@0"

Ndihmë ju lutem

16.08.2013

  • A u lidhët me Canon EOS SDK? 16.08.2013
  • Problemi nuk është kodi, është se ju duhet të lidhni lidhjen në bibliotekë. Mënyra se si e bëni këtë varet nga sistemi operativ dhe mjedisi juaj. 16.08.2013

Përgjigjet:


1

Përshëndetje, ky kod funksionon.

#include <iostream>
#include "EDSDK.h"
#include "EDSDKErrors.h"
#include "EDSDKTypes.h"
#include <thread>
#include <chrono>

char * directory = "Here is your directory";

void download_img(EdsBaseRef & object, EdsVoid * & context)
{
    EdsStreamRef stream = NULL;
    EdsDirectoryItemInfo dirItemInfo;
    EdsGetDirectoryItemInfo(object, &dirItemInfo);
    strcat(directory, file_name);
    EdsCreateFileStream(directory, kEdsFileCreateDisposition_CreateAlways, kEdsAccess_ReadWrite, &stream);
    EdsDownload(object, dirItemInfo.size, stream);
    EdsDownloadComplete(object);
    EdsRelease(stream);
    stream = NULL;
    if (object)
        EdsRelease(object);
}

EdsError EDSCALLBACK handleObjectEvent(EdsObjectEvent event, EdsBaseRef object, EdsVoid * context)
{
    download_img(object, context);
    return EDS_ERR_OK;
}

void init_camera(EdsCameraRef & camera)
{
    EdsError err = EDS_ERR_OK;
    EdsCameraListRef cameraList = NULL;
    EdsUInt32 count = 0;
    camera = NULL;

    err = EdsInitializeSDK();
    err = EdsGetCameraList(&cameraList);
    err = EdsGetChildCount(cameraList, &count);
    if (count > 0)
    {
        err = EdsGetChildAtIndex(cameraList, 0, &camera);
        EdsRelease(cameraList);
    }
    EdsSetObjectEventHandler(camera, kEdsObjectEvent_DirItemCreated, handleObjectEvent, NULL);
    EdsSendStatusCommand(camera, kEdsCameraStatusCommand_UIUnLock, 0);
}

void start_liveview(EdsCameraRef camera)
{
    EdsOpenSession(camera);
    EdsUInt32 device = kEdsPropID_Evf_OutputDevice;
    EdsGetPropertyData(camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);

    device |= kEdsEvfOutputDevice_PC;
    EdsSetPropertyData(camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
}

void stop_liveview(EdsCameraRef camera)
{
    EdsUInt32 device;
    EdsGetPropertyData(camera, kEdsPropID_Evf_OutputDevice, 0, sizeof(device), &device);
    device &= ~kEdsEvfOutputDevice_PC;
    EdsSetPropertyData(camera, kEdsPropID_Evf_OutputDevice, 0,  sizeof(device), &device);
    EdsCloseSession(camera);
}

void take_video(EdsCameraRef camera, int length)
{
    EdsOpenSession(camera);
    EdsUInt32 record_start = 4; // Begin movie shooting 
    EdsSetPropertyData(camera, kEdsPropID_Record, 0, sizeof(record_start), &record_start);
    this_thread::sleep_for(chrono::milliseconds(length));
    EdsUInt32 record_stop = 0; // End movie shooting 
    EdsSetPropertyData(camera, kEdsPropID_Record, 0, sizeof(record_stop), &record_stop);
    EdsCloseSession(camera);
}

void update_data(EdsCameraRef camera)
{
    EdsOpenSession(camera);
    // here event happens
    EdsCloseSession(camera);
}

void take_photo(EdsCameraRef camera, int count, int interv_millsec)
{
    for (int i = 0; i < count; ++i) {
        EdsOpenSession(camera);
        cout << "shoot" << endl;
        EdsSendCommand(camera, kEdsCameraCommand_TakePicture, 0);
        this_thread::sleep_for(chrono::milliseconds(interv_millsec));
        EdsCloseSession(camera);
    }
    update_data(camera);
}

void dispose(EdsCameraRef camera)
{
    EdsCloseSession(camera);
    EdsTerminateSDK();
}

int main (){
    EdsCameraRef camera;
    init_camera(camera);

    // here you may call functions above

    // to take video
    // firstly you have to start liveview
    // secondly call "take video"
    // thirdly stop liveview
    return 0;
}
02.07.2017
  • Vonë në festë, por shpresoj se mund të ndihmoni, unë kam qenë duke luftuar me të njëjtin problem dhe kam provuar kodin tuaj. Megjithatë, handleObjectEvent ende nuk është arritur. A keni ndonjë ide se çfarë tjetër mund të provoj? 22.02.2021
  • @TJasinski pata të njëjtin problem me handleObjectEvent. Për fat të keq nuk e mbaj mend zgjidhjen, por gjeta versionin më të fundit të kodit tim në të cilin u zgjidh ky problem. Unë kam shkruar bibliotekën C për të punuar me Canon Camera, dhe më pas e përdor nga Unity me C#. Shpresoj se do të ishte e dobishme për ju. github.com/oscarmoisei/CanonCameraLibrary/blob/master/ 24.02.2021
  • Shpëtimtar jete! Kjo do të ndihmojë me siguri 25.02.2021
  • Materiale të reja

    Masterclass Coroutines: Kapitulli-3: Anulimi i korutinave dhe trajtimi i përjashtimeve.
    Mirë se vini në udhëzuesin gjithëpërfshirës mbi Kotlin Coroutines! Në këtë seri artikujsh, unë do t'ju çoj në një udhëtim magjepsës, duke filluar nga bazat dhe gradualisht duke u thelluar në..

    Faketojeni derisa ta arrini me të dhënat false
    A e gjeni ndonjëherë veten duke ndërtuar një aplikacion të ri dhe keni nevojë për të dhëna testimi që duken dhe duken më realiste ose një grup i madh të dhënash për performancën e ngarkesës...

    Si të përdorni kërkesën API në Python
    Kërkesë API në GitHub për të marrë depot e përdoruesve duke përdorur Python. Në këtë artikull, unë shpjegoj procesin hap pas hapi për të trajtuar një kërkesë API për të marrë të dhëna nga..

    Një udhëzues hap pas hapi për të zotëruar React
    Në këtë artikull, do të mësoni se si të krijoni aplikacionin React, do të mësoni se si funksionon React dhe konceptet thelbësore që duhet të dini për të ndërtuar aplikacione React. Learning..

    AI dhe Psikologjia — Pjesa 2
    Në pjesën 2 të serisë sonë të AI dhe Psikologji ne diskutojmë se si makineritë mbledhin dhe përpunojnë të dhëna për të mësuar emocione dhe ndjenja të ndryshme në mendjen e njeriut, duke ndihmuar..

    Esencialet e punës ditore të kodit tim VS
    Shtesat e mia të preferuara - Git Graph 💹 Kjo shtesë është vërtet e mahnitshme, e përdor përpara se të filloj të punoj për të kontrolluar dy herë ndryshimet dhe degët më të fundit, mund të..

    Pse Python? Zbulimi i fuqisë së gjithanshme të një gjiganti programues
    Në peizazhin gjithnjë në zhvillim të gjuhëve të programimit, Python është shfaqur si një forcë dominuese. Rritja e tij meteorike nuk është rastësi. Joshja e Python qëndron në thjeshtësinë,..