Magic Lantern Forum

General Discussion => General Chat => Topic started by: petabyte on September 16, 2022, 03:21:50 AM

Title: New PTP Camera Controller App for Android
Post by: petabyte on September 16, 2022, 03:21:50 AM
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.
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: Skinny on September 16, 2022, 09:41:46 AM
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...
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: petabyte on September 16, 2022, 03:25:59 PM
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.
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: names_are_hard on September 16, 2022, 05:30:33 PM
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 :)
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: petabyte on September 16, 2022, 05:47:16 PM
That would be pretty easy, would just have to copy the device name and serial number.
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: petabyte on September 16, 2022, 07:39:25 PM
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
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: petabyte on November 11, 2022, 03:21:02 AM
Updates:
- Implemented screen liveview https://www.youtube.com/watch?v=daW97UECLEo (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"
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: koljanych on November 12, 2022, 10:11:18 PM
what do you think about Canon XC Protocol ?
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: petabyte on November 12, 2022, 11:58:37 PM
Quote from: koljanych on November 12, 2022, 10:11:18 PM
what do you think about Canon XC Protocol ?
Never heard of it
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: Johnny78 on November 15, 2022, 08:25:28 AM
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.
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: petabyte on November 15, 2022, 03:58:43 PM
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.
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: Whr on December 01, 2022, 04:28:36 PM
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
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: domasa on December 01, 2022, 05:08:08 PM
+ date and time synchronization
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: 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.
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: optikus on December 01, 2022, 07:47:39 PM
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
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: petabyte on December 01, 2022, 11:32:55 PM
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.
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: Whr on December 02, 2022, 11:36:53 AM
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.
Title: Re: Brainstorming features for a PTP/USB/IP Android App
Post by: petabyte on December 02, 2022, 08:00:17 PM
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.
Title: Re: New PTP Camera Controller App for Android
Post by: petabyte on December 19, 2022, 04:24:42 AM
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.danielc.dev/f/63-sacuojn5xehdxje3rmoz321iachj5c.png)
https://eggnog.theres.life/f/64-mkgly30jykmfbj14yh6wq3fah4qi7t.png (https://eggnog.danielc.dev/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?
Title: Re: New PTP Camera Controller App for Android
Post by: 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?
Title: Re: New PTP Camera Controller App for Android
Post by: petabyte on December 19, 2022, 06:44:24 PM
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.
Title: Re: New PTP Camera Controller App for Android
Post by: petabyte on January 29, 2023, 03:08:07 AM
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
Title: Re: New PTP Camera Controller App for Android
Post by: dpjpandone on February 02, 2023, 02:09:51 AM
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
Title: Re: New PTP Camera Controller App for Android
Post by: petabyte on February 02, 2023, 07:48:26 PM
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.
Title: Re: New PTP Camera Controller App for Android
Post by: petabyte on May 25, 2023, 09:50:32 PM
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.
Title: Re: New PTP Camera Controller App for Android
Post by: koopg on May 26, 2023, 02:24:10 AM
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