Pure Java (jsr80 usb) interface to the Cannon cameras running CHDK PTP
Interface reference https://github.com/c10ud/CHDK/blob/master/core/ptp.h
This code is has mirrored public repository available under: https://git.man.poznan.pl/stash/projects/KWE/repos/chdk-ptp-java/browse
The codes found there are automatically tested and built as artifacts using Jenkins CI server and uploaded to maven repository: https://maven.man.poznan.pl/repository/webapp/browserepo.html?pathId=kiwi-libs-snapshots:org/chdk/ptp/java/CHDK-PTP-Java
Which can be later used in gradle project by simply defining the repository maven address:
repositories
{
maven() { url 'https://maven.man.poznan.pl/repository/kiwi-repo' } // virtual repo
}
and adding appropriate entry in build.gradle or relevant in pom.xml
dependencies
{
compile 'org.chdk.ptp.java:CHDK-PTP-Java:+'
}
For the sake of usability, rapid development and usage sanity we use semantic versioning: http://semver.org/
Try to follow chdk.ptp.java.standalone.LiveViewApiDemo.java but part of the example is below:
cam = CameraFactory.getCamera(SupportedCamera.SX160IS);
cam.connect();
cam.setOperaionMode(CameraMode.RECORD);
int i = 0;
BufferedImagePanel d = new BufferedImagePanel(cam.getView()); // displays live view
Random random = new Random();
while (true) {
d.setImage(cam.getView());
++i;
cam.setZoom(i % 100);
if (i % 40 == 0) {
cam.setZoom(random.nextInt(100));
}
if (i % 8 == 0) {
cam.setZoom(random.nextInt(100));
cam.setFocus(random.nextInt(1000) + 100);
}
cam.setFocusMode(FocusMode.AUTO);
}
cd ~/
wget https://services.gradle.org/distributions/gradle-2.2-bin.zip
unzip gradle-2.2-bin.zip
echo "export PATH=\$PATH:$HOME/gradle-2.2/bin" >> ~/.bashrc
source ~/.bashrc
Artifactory plugin requires a file
$HOME\.gradle
to be created and filled with the following two lines:
USER=wont_be_used
PASSWORD=but_needs_to_be_here
Spring offers Gradle integration which can be acquired from: https://github.com/spring-projects/eclipse-integration-gradle
Use console git:
mkdir ~/git
cd ~/git
git clone https://github.com/acamilo/CHDK-PTP-Java.git
or Eclipse plugin.
cd CHDK-PTP-Java
gradle build
Import Gradle Project from within Eclipse.
I.E Afternoon wasters...
on some OSes gvfs will grab the PTP device and you'll get this error.
javax.usb.UsbPlatformException: USB error 6: Unable to claim interface: Resource busy
The solutionin ubuntu is this.
gsettings set org.gnome.desktop.media-handling automount false
To un do this change false to true.
Sometimes, cam.setRecordingMode() will fail but the camera will otherise be responsive.
see thread: http://chdk.setepontos.com/index.php?topic=10664.10
solition is to either kill gvfs-gphoto2-volume-monitor or to make it perminent, change it's name so it doesn't start.
This uses libusb4java so it probably works in windows and mac. I've never tried it though.