New PTP Camera Controller App for Android

Started by petabyte, September 16, 2022, 03:21:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

petabyte

EDIT Oct 2023:
Am working on rewriting the frontend of the app. Old frontend was HTML/CSS/JS. I think it's pretty obvious to see why that was a mistake.
New version will have all the same features, but have USB and WiFi connectivity, as well as UPnP discovery.

I've been working on a PTP (Picture Transfer Protocol) library in C lately, with the main intent of making a DSLR controller Android app out of it.

Features that will come in the first release:
- Get Live EOS viewfinder image (can't use while recording)
- Interface with ML - Live screen data (320x240, see all Canon menus and ML menus while recording RAW or MOV)
  Not a solid replacement for HDMI, but useful (in case you don't have a HDMI adapter, or it blocks the USB port)
  Currently 15fps - should be possible to optimize (see https://github.com/petabyt/ptpview)
- Scripting in Javascript (scripts can run on demand or in background)
- Get live aperture+ISO+shutter speed+image format+battery
- Raise flash
- Take pictures and do BULB shots
- Image/File explorer
- Extensive settings and customization
- Plugins/mods/scripts written in Javascript (run on demand or in background, can modify UI)
- Script generator (timelapse)

Here are features I'll probably add in the future, other than the typical features you'd expect in a camera app:
- Sync camera video start time with phone, use internal phone mic as camera mic
- ML Like overlays over live view
Looking for suggestions :) - I only do astrophotography with my camera, so the feature set will be biased.

- The app will not only run on Android, but Linux too (as a web server). It would be possible to connect a Raspberry Pi to your DSLR and control your camera from inside (or technically, anywhere in the world)
- iOS support is not out of the question, but it would be a learning curve. I've never used an modern Apple device apart from when I fixed them, and I don't know how iOS apps are made.
- It's worth noting that the PTP library I made is very portable (and open source, https://github.com/petabyt/camlib) and can easily be compiled and ported to different platforms.
- The user interface for the app is written in HTML/CSS/JS and is layered over a graphics canvas, where the liveview is drawn. The app is mostly C and Javascript. Under 500 lines of Java code is required the the entire app to work.

Skinny

I think it is a great idea. :) If you can make DSLR controller compatible with ML - it can replace hdmi monitors and remote control.

For extra features...

  • An option to see clearly if something is connected to the USB and if DSLR is detected, etc. so - detailed status information. Because with existing android apps it is really hard to tell if everything is connected and why it doesn't work sometimes.. Especially if I'm trying to use long cables and so on.
  • And if connection with the camera is lost, reconnect everything automatically..
  • Probably at least some compatibility with ML raw..
  • It could be very cool if the app can trick the phone to think that the DSLR is one of built-in android cameras, if it is possible at all. With this option it will be very fast and easy to take a picture with DSLR and immediately upload it on social media such an instagram for example, without saving and transfering the file. Like it is native phone camera.

petabyte

All great ideas. When I was testing, the PTP liveview cut off when I started recording RAW or MOV. There's a slim chance there's a way around this, but I'm not sure.
A packet transmission status was exactly what I was thinking of, maybe an icon in the bottom that lights up green when packets are being received or sent.

names_are_hard

Per cam profiles could be nice.  Assumes there is some unique cam ID you can get, I guess likely.  Not sure what people would use them for since it depends on what other features you implement :)

petabyte

That would be pretty easy, would just have to copy the device name and serial number.

petabyte

I'm also very slowly working on LibUSB and WinUSB backends for this lib, so chances are it might find it's way into https://github.com/petabyt/mlinstall/ someday

petabyte

Updates:
- Implemented screen liveview https://www.youtube.com/watch?v=daW97UECLEo
Very slow, ~5fps transferring 259k per frame, should eventually be improved to ~30fps (?)
- MOV recording is possible while transmitting screen data - haven't tested RAW yet
- Base code for the app is implemented - stable data transmission, connecting/disconnecting, working backend (hardest part finished)
- It's written mostly in C99, which communicates with some Java code via JNI. The frontend will be written in JS/HTML/CSS (WebView), which will be transparent over the graphical canvas element.
- The app will allow custom JS scripts to be run/loaded to provide extra functionality - this is where ML interconnectivity can be implemented.
- The app will be sold on Google Play.
- While I'm working on the Android/Java backend, I'm also working on a LibUSB backend (WinUSB soon, hopefully) and implementing a browser based version.
Eventually, a WiFi connected raspberry pi could be plugged into the camera, which would host a control panel that could be accessed by any device on the same network.

TODO List:
- Design modern user interface, find icons
- Implement ~10 PTP opcodes
- Implement ~30 canon/eos opcodes
- Implement parsing/packing of object structures + into/from JSON
- Ensure LibUSB backend is reliable/stable
- Design a PTP API for Javascript
- Implement PTP/IP support - I think it's less complicated than USB, but painfully unreliable
- Sort out JPEG decoding/encoding
- Decide on a good name... currently "CamControl"

koljanych


petabyte


Johnny78

Quote from: koljanych on November 12, 2022, 10:11:18 PM
what do you think about Canon XC Protocol ?

What is this protocol ? Like @petabyte, I've never heard of it.

petabyte

Quick google search shows it's a completely new IP based protocol created by Canon, for their very high end cameras.
Has nothing to do with PTP, so this app will never support it. Even if I could support it, I'm nowhere near getting my hands on a $2000 cinema camera.

Whr

I have an idea
Is it possible to write GPS information to the photo EXIF via the phone GPS? I think this would be useful for travel photography
500D 1.1.1 & X-T3

domasa


petabyte

Time sync is possible I think. GPS - I don't know. Would be vendor specific I guess.
Still working on this consistently - just a time consuming and difficult project.

optikus

Hello,

it would be very useful to implement "B" (in B-mode) with unlimited time via USB/Wifi on those cameras, which cannot perform "B" correctly as the "M" and others where it is blocked in EOS-Utility-software.

Kind regards
Jöerg

petabyte

Bulb mode is easy to implement, at least for Canon. Trying to design everything so a Nikon/Sony/Fuji extension would be as easy as possible.

Whr

Quote from: petabyte on December 01, 2022, 07:35:59 PM
Time sync is possible I think. GPS - I don't know. Would be vendor specific I guess.
Still working on this consistently - just a time consuming and difficult project.

Maybe there's some other way to achieve the GPS function. It just works as a GPS logger, recording phone location every minute(or at a specific time). When users use their phone to output photos from the camera, the app will automatically write the location to EXIF. At the same time, the software can export the location information for a time period as a separate file and the user can write the photo location information in batches on the computer using ExifTool.
500D 1.1.1 & X-T3

petabyte

Quote from: Whr on December 02, 2022, 11:36:53 AM
Maybe there's some other way to achieve the GPS function. It just works as a GPS logger, recording phone location every minute(or at a specific time). When users use their phone to output photos from the camera, the app will automatically write the location to EXIF. At the same time, the software can export the location information for a time period as a separate file and the user can write the photo location information in batches on the computer using ExifTool.
I can say this: whatever the EOS apps can do, I can do.

petabyte

Update:
I've made a lot of progress - bulb works, focus works, mirror flipping works, live get/set ISO/aperture/shutter speed/image format is almost done, and liveview works (on Linux and Android)
Now I need to make the HTML/CSS/JS user interface a little better. This is what I'm currently working on:
https://eggnog.theres.life/f/63-sacuojn5xehdxje3rmoz321iachj5c.png
https://eggnog.theres.life/f/64-mkgly30jykmfbj14yh6wq3fah4qi7t.png
Currently I've been testing it mostly in portrait mode, but I think users will be in landscape mode the most (with a phone mounted to the flash mount).
Having both won't be impossible, but it might require a lot of planning and CSS magic (and likely some JS stuff too) to make everything fit properly and not overlap.

So I'm asking a bunch of camera nerds, what UI layout would be optimal? Would you ever use portrait mode? What should I tweak in my current design?

Skinny

I think an option to turn the display 90 and 180 degrees as well as mirroring it could be useful in some situations.. What about RAW recording while using your app?

petabyte

Quote from: Skinny on December 19, 2022, 11:05:08 AM
I think an option to turn the display 90 and 180 degrees as well as mirroring it could be useful in some situations.. What about RAW recording while using your app?
PTP while recording MOV/MLV is possible. I've hardly tested my custom liveview module (for liveview while recording) but it works while recording both formats. Unstable currently, but works.

petabyte

And finally, after 4 months... I'm still not finished yet.

I've finished most of the features I planned for v0.1.0. ML + EOS Liveview, remote capture/bulb, get/set WB, ISO, shutter speed, aperture, focus lens, basic file manager, etc. I've also got about a dozen other small things I need to implement and test.

I decided to build a new app on top of my existing camlib/camcontrol code. It's a very basic intervalometer app, with a section for JS scripting, standard and bulb capture.
This is mainly a basic tech demo to test my current implementation of PTP, and my understanding of Android USB communication. I've tested it as much as I can, but I haven't fuzz/stress tested it yet, so there's a slight chance it may have some bugs. After stress testing, I will upload it to the play store.

APK Download: https://github.com/petabyt/camlib/releases/tag/caminterv-1

dpjpandone

This has potential to be very useful. Most timelapses I am interested in recording end up with the camera in a very uncomfortable position to have to program the damn intervalometer from the LCD

petabyte

Thanks. Hopefully will have WiFi support for the next release. I know how to do it, but it would be tedious. iOS support is also theoretically possible, just need to get my hands on a mac and iphone.

petabyte

Had put it up on Google play a while ago: https://play.google.com/store/apps/details?id=dev.petabyt.camcontrol
I had intended to add a lot more features (WiFi support, Nikon/Sony/Fuji support, more ML features),
but development ended up taking way too long (over 6 months). 70% of the app was written in HTML/CSS/JS, so
I ended up having to write a ton of boilerplate code to manage things like hardware communication, background tasks, and UI.

koopg

I have this working from2015
over raspbarry pi

if you need anything..
my controoler runs python
gphoto2
and some more goodies



Sent from my SM-N975F using Tapatalk