GithubHelp home page GithubHelp logo

blackdread / canon-sdk-java Goto Github PK

View Code? Open in Web Editor NEW
86.0 9.0 16.0 1.48 MB

Canon EOS SDK in java. Wrapper for Canon EOS Digital Software Development Kit EDSDK.

License: MIT License

Java 100.00%
java canon camera jna jni sdk canon-edsdk canon-camera edsdk canon-eos-sdk

canon-sdk-java's Introduction

Build Status Coverage Status Maven Central Github Workflow StackShare

Canon EOS SDK (EDSDK)

Canon EOS SDK in java (EDSDK).

Latest headers used to create bindings are with EDSDK 13.10.0 (version released on February 23rd 2019)

See Bindings README for more detailed information of that module

See Framework README for more detailed information of that module, important design is explained about Threads and events.

Project motives

Project intend to give access to Canon EOS Digital Software Development Kit EDSDK in Java.

Features are:

  • Take and download pictures
  • Set parameters like Aperture, ISO Speed, etc
  • Use live view
  • Control multiple cameras
  • Simple extendable recorder implementation

Support for MAC OSX is not intended for now, but only few changes in implementation should be required to make it work. Only changes in library loader class should be needed.

Both 64 bit and 32 bit versions are supported.

Java versions

Minimum Java 8 is required. Works with JDK 8/11/14+

Maven dependency

To control camera, use the framework:

<dependency>
    <groupId>org.blackdread</groupId>
    <artifactId>camera-framework</artifactId>
    <version>put version here</version>
</dependency>

If you only want bindings then just change artifact to "camera-binding" but framework should be what you should use as it gives commands, etc.

Usage

See package "org.blackdread.cameraframework.demo" in test folder (here).

Support project

To help me to maintain and add more features, you can be a sponsor.

Company support and sponsor

For companies that desire support, help, or even sponsor, etc feel free to contact me on LinkedIn https://www.linkedin.com/in/yoanncaplain/ (preferred way) or via an email form).

Commercial technical support and services are possible.

Design note

Any collection/map return type should be considered as immutable, even if implementation does not use ImmutableList/Set/etc. If collection/map is mutable, it will be clearly specified in javadoc, otherwise implementation is free to change to immutable collections anytime.

How to contribute pull requests

Do a pull request. Explain your changes, reasons, write tests.

Get EDSDK library from Canon

Analysis with sonar

sonar-quality-gate sonar-coverage sonar-bugs sonar-vulnerabilities sonar-code-lines

Previous project

This library started from scratch due to edsdk4j that was not maintained; And I wanted to implement a complete different code architecture.

Software example using this Framework/SDK

Example 1

canon-sdk-java's People

Contributors

blackdread avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

canon-sdk-java's Issues

[BUG] Cannot find NativeEnum classes from ClassPath with Spring Boot jar

Fail to get classes on class path when use framework as a dependency in another Spring boot project that is packaged into an executable jar via spring-boot-maven-plugin.

Line
final ImmutableSet<ClassPath.ClassInfo> allClasses = ClassPath.from(EdsAccess.class.getClassLoader()).getTopLevelClasses(NATIVE_ENUM_PACKAGE);
will return an empty set (in ConstantUtil).

Issue does not occur if package into an executable jar via shade/assembly/etc => no spring specific jar layout

EDSDK - Request Autofocus without stopping liveview image retrieval

Hello everyone,

Thank you for this very useful library.

I have a question concerning only the EDSDK.

I'd like to be able to autofocus while retrieving images from the liveview.

In my case, when I autofocus, image retrieval stops and starts again once I've received the autofocus command.
I use the :
SendCommand(kEdsCameraCommand_PressShutterButton, kEdsCameraCommand_ShutterButton_Halfway) ;
Is this possible? This function is available via Canon's EOS Utility application.

Thank you for taking the time to read this document.

Failed to get property type and size of kEdsPropID_BodyIDEx (EDS_ERR_COMM_DISCONNECTED), inParam 0. Probably not supported by camera

Hi,

I´m trying this lib to connect my Canon 1300d.
The lib / dll files is found and i placed all the files in my project.
My camera is also switched on.
Is there any specifc settings which I have to do on the camera?
I´m getting this error message:

Failed to get property type and size of kEdsPropID_BodyIDEx (EDS_ERR_COMM_DISCONNECTED), inParam 0. Probably not supported by camera

Do I need a memory card inside the cam?
I see also during I start the program that the screen is poping up for 1 sec from the camera, so it seems there is a connection...

Here my log:
Aug. 02, 2022 12:13:29 NACHM. org.blackdread.cameraframework.api.helper.factory.CanonLibraryImpl registerCanonShutdownHook INFORMATION: Registered shutdown hook of library Aug. 02, 2022 12:13:29 NACHM. org.blackdread.cameraframework.api.helper.factory.CanonLibraryImpl initLibrary INFORMATION: Library successfully loaded Aug. 02, 2022 12:13:47 NACHM. org.blackdread.cameraframework.api.helper.factory.PropertyLogicDefault getPropertyTypeAndSize SCHWERWIEGEND: Failed to get property type and size of kEdsPropID_BodyIDEx (EDS_ERR_COMM_DISCONNECTED), inParam 0. Probably not supported by camera Aug. 02, 2022 12:13:47 NACHM. org.blackdread.cameraframework.api.helper.factory.CameraLogicDefault openSession INFORMATION: Error ignored while testing if camera is connected to open session org.blackdread.cameraframework.exception.error.communication.EdsdkCommDisconnectedErrorException: Port disconnected at org.blackdread.cameraframework.api.constant.EdsdkError.getException(EdsdkError.java:411) at org.blackdread.cameraframework.api.helper.factory.PropertyLogicDefault.getPropertyTypeAndSize(PropertyLogicDefault.java:64) at org.blackdread.cameraframework.api.helper.factory.PropertyGetLogicDefault.getPropertyData(PropertyGetLogicDefault.java:72) at org.blackdread.cameraframework.api.helper.logic.PropertyGetLogic.getPropertyData(PropertyGetLogic.java:88) at org.blackdread.cameraframework.api.helper.logic.PropertyGetShortcutLogic.getBodyIDEx(PropertyGetShortcutLogic.java:87) at org.blackdread.cameraframework.api.helper.factory.CameraLogicDefault.openSession(CameraLogicDefault.java:163) at org.blackdread.cameraframework.api.command.OpenSessionCommand.runInternal(OpenSessionCommand.java:60) at org.blackdread.cameraframework.api.command.OpenSessionCommand.runInternal(OpenSessionCommand.java:38) at org.blackdread.cameraframework.api.command.AbstractCanonCommand.run(AbstractCanonCommand.java:131) at org.blackdread.cameraframework.api.helper.factory.SingleCommandDispatcher.commandDispatcher(SingleCommandDispatcher.java:152) at java.base/java.lang.Thread.run(Thread.java:829)

I´m using:
Windows 8.1 Pro
64 Bit

Ways to determine if camera is ON or OFF?

Hello,

Sorry for asking questions here but support is rather limited for the EDSDK. I have searched everywhere and i couldn't see anything. By any chance, do you know if there is a way to determine if camera is ON or OFF? I mean is there an event or something that i can rely on to determine if the camera been disconnected? Because the method GetAllConnectedCamera will still return the camera even if its not available (unplugged for example).

Thanks for your help! That would be my last question.

Use the lib for MacOS?

Hi,

I´m developing on MacOs and not Windows. Therefore I would need it also for MacOS.

The path / files seems like is not the same as in Windows?
Is this an issue?

image

image

What needs to be changed to use it for MacOS?
Thanks

Which event is the right one for downloading image from camera

When shooting images one after another (not multiple at once, but shoot-download-shoot-download), I had a problem with busy camera. I think it's caused by reacting to bad event - I've noticed that one image was downloading two times.

Please, what is the right event to react on? I think it's kEdsObjectEvent_DirItemRequestTransfer and we should skip kEdsObjectEvent_DirItemCreated in Shoot task.

[REQUEST] SDK copy

Hi.
Can someone please help me with copy of the sdk. I want to have a play to see if I can contribute.
I'm in Australia and despite there being no link on the Oceania site to actually apply, Oceania Canon is the most useless arm in the whole company anyway. If they even did have a link nobody would reply. It's always been like this from development to camera firmware.

If anyone can help me that would be great. Thanks.

[BUG] CameraAddedEvent do not properly update the cameras

When i receive the CameraAdded event. I expected the CameraManager.getAllCamera() to have it but the list had no elements. So i have no way to actually get the added camera so i can call openSession on it.

In the IDE, if i call refreshCamera before calling getAllCamera it work.. but refreshCamera isn't a public method. Technically, it should have been called if i did setRefreshInterval to 0 but it doesn't look like to be called in reality.

Here what i do,,

private CameraAddedListener cameraAddedListener = event -> {
    cameraConnected = true;

    Platform.runLater(() -> initializeCameraConnexion());
    log.info("Camera added detected: {}", event);
  };

then..

public void initializeCameraConnexion() {
    log.info("initializeCameraConnexion()");

    if (CameraManager.getAllCameras().size() > 0) {
      this.camera = CameraManager.getAllCameras().get(0);
    }

If i look at the getAllCameras() here the results...
https://i.imgur.com/sReHBLC.png

Now if i refresh manually just before here the results...
https://i.imgur.com/yMSSwDZ.png

Problem i have is that calling refreshCameras was possible because i am in the IDE but this method is not public. There is no way to instant refresh manually the cameras list.

[REQUEST] Get shoot as stream

Hi,

Is it possible with your wrapper to get the shoot in a Stream ? I Don't want to save file on the PC.

Thank

Jimmy Simard

shoot.shoot() -> get an Stream not a file?

I see the following code will take a picture:

Shoot shoot = camera.getShoot();
List<File> file = shoot.shoot();

Currently the picture is saved in a temp folder.
Is there also a possibility to get only a OutputStream?
Or do I need to get an outputstream from the file and delete the file afterwards? (not the best for performance!)

Any ideas?

Live View -> any example?

Hi,

I would like to enable the live view in my GUI.

I want to do:

  • Get live view
  • Send Stream / Image to my JSF Controller
  • Output Image as Stream

How can I do this... any examples etc.?
How does this general technically works? Do I have to send many images to my JSF Controller etc.?

Thanks for any help

PTP IP Connection

does this sdk support ptp ip connection ? basically connecting to canon eos via wifi like in gphoto2

help and/or issues

Hello,

I try to make the sdk working in an java/javafx project. I final goal isto show the camera preview, take a picture and import it on the computer.

I work with a netbeans project. The project is a maven project and i put this on the pom

        <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
        <!-- For test class -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.5.0-M1</version>
            <type>jar</type>
        </dependency>        
        <!-- https://mvnrepository.com/artifact/org.blackdread/camera-binding -->
<dependency>
    <groupId>org.blackdread</groupId>
    <artifactId>camera-binding</artifactId>
    <version>1.1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.blackdread/canon-sdk-java -->
<dependency>
    <groupId>org.blackdread</groupId>
    <artifactId>canon-sdk-java</artifactId>
    <version>1.1.4</version>
    <type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.blackdread/camera-framework -->
<dependency>
    <groupId>org.blackdread</groupId>
    <artifactId>camera-framework</artifactId>
    <version>1.1.4</version>
</dependency>

I create a standard javafxml main class and try to use some code from the demo directory.

Some code can be useless for my trouble you can skip it if i miss to remove it.

import java.util.List;
import java.util.concurrent.ExecutionException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.fxml.JavaFXBuilderFactory;

import org.blackdread.camerabinding.jna.EdsdkLibrary;
import org.blackdread.cameraframework.api.camera.CameraManager;
import org.blackdread.cameraframework.api.camera.CanonCamera;
import org.blackdread.cameraframework.api.command.CanonCommand;
import org.blackdread.cameraframework.api.command.TerminateSdkCommand;
import org.blackdread.cameraframework.api.constant.EdsISOSpeed;
import org.blackdread.cameraframework.api.constant.EdsSaveTo;
import org.blackdread.cameraframework.api.helper.factory.CanonFactory;
import org.blackdread.cameraframework.api.helper.initialisation.FrameworkInitialisation;
import org.blackdread.cameraframework.api.helper.logic.event.CameraAddedListener;
import org.blackdread.cameraframework.api.helper.logic.event.CameraObjectListener;
import org.blackdread.cameraframework.api.helper.logic.event.CameraPropertyListener;
import org.blackdread.cameraframework.api.helper.logic.event.CameraStateListener;
import org.junit.jupiter.api.Assertions;


public class Launcher extends Application {
 

    private CameraAddedListener cameraAddedListener;
    private CameraObjectListener cameraObjectListener;
    private CameraPropertyListener cameraPropertyListener;
   private CameraStateListener cameraStateListener;
    
  
    public static void main(String[] args) {
        launch(args);
    }
    @Override
    public void start(Stage primaryStage) {

        this.camTest();
        
      }

    private void camTest()
    {
        cameraAddedListener = event -> {
            System.out.println("Camera added detected: "+ event);
        };
        cameraObjectListener = event -> {
            System.out.println("Object event: "+ event);
        };
        cameraPropertyListener = event -> {
            System.out.println("Property event: "+ event);
        };
        cameraStateListener = event -> {
            System.out.println("State event: "+ event);
        };
        new FrameworkInitialisation()
            .registerCameraAddedEvent()
            .withEventFetcherLogic()
            .withCameraAddedListener(cameraAddedListener)
            .initialize();

        final List<CanonCamera> cameras = CameraManager.getAllCameras();

        Assertions.assertFalse(cameras.isEmpty());

        final CanonCamera camera = cameras.get(0);

        final EdsdkLibrary.EdsCameraRef edsCameraRef = get(camera.openSession());
//        camera.setCameraRef(edsCameraRef); // not necessary as by default on success the ref is set by the openSession command

        // optional as manager does it
        get(camera.getEvent().registerObjectEventCommand());
        get(camera.getEvent().registerPropertyEventCommand());
        get(camera.getEvent().registerStateEventCommand());

        CanonFactory.cameraObjectEventLogic().addCameraObjectListener(cameraObjectListener);
        CanonFactory.cameraPropertyEventLogic().addCameraPropertyListener(edsCameraRef, cameraPropertyListener);
        CanonFactory.cameraStateEventLogic().addCameraStateListener(edsCameraRef, cameraStateListener);

        final String artist = get(camera.getProperty().getArtistAsync());
        System.out.println("artist: "+ artist);

        final String serial = get(camera.getProperty().getBodyIDExAsync());
        System.out.println("serial: "+ serial);

        final EdsISOSpeed isoSpeed = get(camera.getProperty().getIsoSpeedAsync());
        System.out.println("isoSpeed: "+ isoSpeed);

        final EdsSaveTo saveTo = get(camera.getProperty().getSaveToAsync());
        System.out.println("saveTo: "+ saveTo);

        get(camera.closeSession());

CanonFactory.commandDispatcher().scheduleCommand(new TerminateSdkCommand());

    }
    
    

    private static <R> R get(final CanonCommand<R> command) {
        try {
            return command.get();
        } catch (InterruptedException | ExecutionException e) {
            throw new IllegalStateException(e);
        }
    }
    
   
}

When i build there is no trouble but when i run i add this error :

[cmd-dispatcher-0] INFO org.blackdread.cameraframework.api.helper.factory.CanonLibraryImpl - Dll auto selected to 32 bit
[cmd-dispatcher-0] WARN org.blackdread.cameraframework.api.helper.factory.SingleCommandDispatcher - Command dispatcher thread ended
Exception in thread "cmd-dispatcher-0" java.lang.Error: Le chemin d’accès spécifié est introuvable. // This means the specify path can't be found

	at com.sun.jna.Native.open(Native Method)
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:171)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
	at com.sun.jna.Library$Handler.<init>(Library.java:147)
	at com.sun.jna.Native.loadLibrary(Native.java:412)
	at org.blackdread.cameraframework.api.helper.factory.CanonLibraryImpl.initLibrary(CanonLibraryImpl.java:150)
	at org.blackdread.cameraframework.api.helper.factory.CanonLibraryImpl.edsdkLibrary(CanonLibraryImpl.java:95)
	at org.blackdread.cameraframework.api.helper.factory.CanonFactory.edsdkLibrary(CanonFactory.java:155)
	at org.blackdread.cameraframework.api.command.InitializeSdkCommand.runInternal(InitializeSdkCommand.java:50)
	at org.blackdread.cameraframework.api.command.InitializeSdkCommand.runInternal(InitializeSdkCommand.java:39)
	at org.blackdread.cameraframework.api.command.AbstractCanonCommand.run(AbstractCanonCommand.java:131)
	at org.blackdread.cameraframework.api.helper.factory.SingleCommandDispatcher.commandDispatcher(SingleCommandDispatcher.java:152)
	at java.lang.Thread.run(Thread.java:748)

I translate the error message. I think it can come from several sources (but maybe from an other)

  • the path for the sdk i provide is wrong (i put it on the netbeans project ressource directory)
  • the code need class it can't be reach, i can t use some classes like IsConnected or DllOnPath.

Thx for your help.

Path can be customized in CanonLibraryImpl?

Hi,

I would like to know how can I customize the path?
Which kind of code do I need to set it to a specific path?

On the other hand I understood it also, that I can place the whole EDSDK / EDSDK64 folder in the "Ressource" folder from the Java project and it will be recognized automatically?

Thanks,

Video capture

Hi,

Can this be used for shooting video?
Now or in the near future

Thank you

Path change for DLL etc.?

Hi,

In your readme is written I can change the path:

image

Can you let me know how can I change this via code example?
I would like to have the files in

src/main/resources/Camera/Canon/Windows/EDSDK
src/main/resources/Camera/Canon/Windows/EDSDK_64

Thank you

CameraRef is null

Hi,

Try to start use this wrapper, but have some problems on start
I use code from demo and always get "CameraRef is null" exeption in camera.openSession() method
If use CameraManager.getAllCameras().get(0) it's ok and i get my camera (but it some others issues in demo code for me)
If use new CanonCamera() in edsdk4j it's ok and i get my camera.

Thank you

void tryOne() {
        cameraAddedListener = event -> {
           log.info("Camera added detected: {}", event);
        };
        cameraObjectListener = event -> {
            log.info("Object event: {}", event);
        };
        cameraPropertyListener = event -> {
            log.info("Property event: {}", event);
        };
        cameraStateListener = event -> {
            log.info("State event: {}", event);
        };
        
        new FrameworkInitialisation()
                .registerCameraAddedEvent()
                .withEventFetcherLogic()
                .withCameraAddedListener(cameraAddedListener)
                .initialize();

        final CanonCamera camera = new CanonCamera();  //camera have empty props     
        final EdsdkLibrary.EdsCameraRef edsCameraRef = get(camera.openSession());
        // ...
}

Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: CameraRef is null
at org.blackdread.cameraframework.api.camera.CanonCamera.lambda$getCameraRefInternal$0(CanonCamera.java:149)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.blackdread.cameraframework.api.camera.CanonCamera.getCameraRefInternal(CanonCamera.java:149)
at org.blackdread.cameraframework.api.camera.CanonCamera.dispatchCommand(CanonCamera.java:133)
at org.blackdread.cameraframework.api.camera.CanonCamera.openSession(CanonCamera.java:286)
at pdcanoncamera.PDCanonCamera.tryOne(PDCanonCamera.java:182)

camera-framework 1.1.1
EDSDK 3.9.0
win10 (x64)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.