[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set AFL(autofocus locking) in libgphoto2 #91

Open
lwj0216 opened this issue Sep 21, 2016 · 2 comments
Open

How to set AFL(autofocus locking) in libgphoto2 #91

lwj0216 opened this issue Sep 21, 2016 · 2 comments

Comments

@lwj0216
Copy link
lwj0216 commented Sep 21, 2016

Hi, I am developing a application and using Nikon D3300 controlled by libgphoto2 on ubuntu14.04. I found that the camera couldn't auto focus successfully in the darkness, so that the method capture_to_file() return failed code and print error message: "Context Error, Out Of Focus". I wonder if there is a way to set AFL by linux shell command or c/c++ code. My idea is that calling AFL method when calling autofocus method return GP_OK in brightness and then turn to darkness so the camera can take a picture successfully.
Thank you!

@msmeissn
Copy link
Contributor

there is the "aelaflmode" config variable, ... However it seems as if the D3300 does not expose it via its API . :/

@lwj0216
Copy link
Author
lwj0216 commented Nov 11, 2016

Thank you for your reply and i am so sorry for that i didn't notice your anwser. It has been confirmed that the D3300 does not support AFL via its API. So i tried to capture the image in LiveView mode and it did work for me. But now i meet some problem when i using gp_camera_capture_preview to get preview image data in a while loop and i get the error message below:
// error log start
errordumper error:Writing 16 = 0x10 bytes to port failed: Error writing to the port (-35)
errordumper error:PTP_OC 0x1015 sending req failed: Error writing to the port (-35)
errordumper error:Writing 16 = 0x10 bytes to port failed: Error writing to the port (-35)
errordumper error:PTP_OC 0x1015 sending req failed: Error writing to the port (-35)
errordumper error:Writing 16 = 0x10 bytes to port failed: Error writing to the port (-35)
errordumper error:PTP_OC 0x1016 sending req failed: Error writing to the port (-35)
errordumper error:Writing 16 = 0x10 bytes to port failed: Error writing to the port (-35)
errordumper error:PTP_OC 0x1016 sending req failed: Error writing to the port (-35)
errordumper error:'ptp_setdevicepropvalue (params, PTP_DPC_NIKON_RecordingMedia, &value, PTP_DTC_UINT8)' failed: PTP I/O Error (0x02ff)
errordumper error:Writing 12 = 0xc bytes to port failed: Error writing to the port (-35)
errordumper error:PTP_OC 0x9201 sending req failed: Error writing to the port (-35)
errordumper error:Writing 12 = 0xc bytes to port failed: Error writing to the port (-35)
errordumper error:PTP_OC 0x9201 sending req failed: Error writing to the port (-35)
errordumper error:'ret' failed: Nikon enable liveview failed (0x02ff: PTP I/O Error)
errordumper error:Nikon enable liveview failed (0x02ff: PTP I/O Error)

*** Contexterror ***
Nikon enable liveview failed (0x02ff: PTP I/O Error)
errordumper error:'camera->functions->capture_preview ( camera, file, context)' failed: -7
// error log end
The code is sometimes normal but sometimes i just meet the error presented above.
That is my code snippet:
while(this->mCaptureFlag)
{
CameraFile file;
char * imageData;
retval = gp_file_new(&file);
retval = gp_camera_capture_preview(this->mCamera, file, this->mContext);
if (retval != GP_OK)
{
Log::getInstance()->error(TAG, "gp_camera_capture_preview failed...");
break;
}
else
{
retval = gp_file_get_data_and_size(file, (const char
*)&imageData, &imageSize);
if(retval != GP_OK)
{
Log::getInstance()->error(TAG, "gp_file_get_data_and_size failed...");
}
char *data = (char *) malloc(imageSize);
memcpy(data, imageData, imageSize);
gp_file_unref(file);

    if(this->isFinishedFrame)
    {
        this->isFinishedFrame = false;
        emit signalSendToVideoThread(data, imageSize);
    }
    else
    {
        delete data;
    }
}
QThread::msleep(20);

}

I wonder if i didn't use the api well, thus the application went wrong ? Thank you for your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants