Author Topic: Help with development (Coding Doubts)  (Read 13340 times)

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Help with development (Coding Doubts)
« on: January 24, 2017, 04:35:15 PM »
Hy guys, I am starting this new topic in order to solve some specific coding doubts that I have. Maybe this thread does not respect the ML forum rules, or maybe yes, but I think that it could help. I'm currently working on a new feature for ML but I am not an expert on programming it. I am on my last degree on informatic/audiovisual year and I've learned how to code, but ML is huge and I am lost sometimes.

Here are my current doubts:

1. It is possible to access the image buffer of the camera when we are not recording? And when we are recording?

2. It is possible to save a sequence of photos on the memory RAM of the camera or on the SD card and then read it from there? I explain you the problem - My purpose is to take some pictures, save them on the memory, then perform some computations with these images and then use the result (reading it from the memory) to apply a concret method.

Thank you all, and I hope that this could help.
Let's keep ML high.

Licaon_Kter

  • Hero Member
  • *****
  • Posts: 519
  • M
Re: Help with development (Coding Doubts)
« Reply #1 on: January 24, 2017, 05:17:58 PM »
You know you have very little memory to work with, right?

Read from post #30 onwards: http://www.magiclantern.fm/forum/index.php?topic=5071.msg166799#msg166799

Also, could you do this (whatever you want) from LUA scripting instead? (memory limitated still)

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #2 on: January 24, 2017, 05:30:49 PM »
Thanks for your time Licaon_Kter!
What is the advantage of using Lua?

Licaon_Kter

  • Hero Member
  • *****
  • Posts: 519
  • M
Re: Help with development (Coding Doubts)
« Reply #3 on: January 24, 2017, 06:07:30 PM »
You can start coding right away... see http://www.magiclantern.fm/forum/index.php?topic=14828.0

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: Help with development (Coding Doubts)
« Reply #4 on: January 24, 2017, 06:38:50 PM »
For temporary uses like image processing there is actually quite a huge amount of memory available (you may need to use the memSuites rather than a simple malloc call, see raw_rec.c or mlv_rec.c)

The memory limitation is mainly for permanently wired stuff like executable code and data that needs to persist the entire time the camera is on.

Lua cannot currently do image processing.

To answer OP's original questions:

1. Yes

2. Yes, see silent.c for how to capture and save LV or FRSP image buffers, or have a look at ettr.c for how to also capture and do some processing on LV or QR image buffers. Also see raw.c for some of the lower level routines that are used by these modules.

Note:
We have recently been learning more about the hardware image processing capabilities in the cameras and depending on exactly what you are trying to do, it may be possible to utilize those capabilities see: http://www.magiclantern.fm/forum/index.php?topic=13408.0 . Keep in mind that if you don't use hardware modules for processing, your code may run quite slowly, the CPUs in these cameras are quite slow. For example even something as simple as reversing the endianess of the image buffer for saving DNG can take on the order of seconds (using Canon compression hardware for DNG writing is on the order of 10s of milliseconds: http://www.magiclantern.fm/forum/index.php?topic=18443.msg176631#msg176631)

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #5 on: January 24, 2017, 07:36:41 PM »
Such a good new to read your post dmilligan !!!  :) It is amazing to receive such help from experts, you are helping me a lot.
Now I'm working on LUA, trying to understand how to use it. I've loaded the lua.mo module, but when I reboot the camera the following message appears:

Quote
PANIC: unprotected error in call to Lua API (not enough memory) abort

Does it mean that the SD card memory is not enough? How can I solve it?

Thank you again guys!


dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: Help with development (Coding Doubts)
« Reply #6 on: January 24, 2017, 07:57:04 PM »
It's talking about RAM, not SD. Either delete some or all of the built in scripts from the SD card or try using an experimental Lua build from here: https://builds.magiclantern.fm/experiments.html

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #7 on: January 24, 2017, 08:48:28 PM »
Actually, I've format the SD card from the camera (Is that what you mean by saying delete some or all of the built in scripts from the SD card ?). Then, I just install ML and load lua.mo and this error appears.

dfort

  • Guest
Re: Help with development (Coding Doubts)
« Reply #8 on: January 24, 2017, 09:52:22 PM »
On the SD card there is an ML folder and in that folder is a "scripts" folder with a bunch of lua files. Delete the scripts that you are not going to be using.

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #9 on: January 24, 2017, 11:00:49 PM »
Thank you dfort!!! I'll be updating this post so that to keep you all informed.  :)

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #10 on: January 27, 2017, 05:28:13 PM »
Hy! It's me again.
I'm trying to call the focus function from lens library (LUA) and I get syntax error every time. I've searched for it on the LUA API and I've found this:

focus (num_steps[, step_size=2[, wait=true[, extra_delay=0]]])

and this:

lens.focus(steps,[step_size],[wait],[extra_delay]

I don't think it is correct...I've proved and it is not working. How do I have to call the function?
Thank you.

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 2218
Re: Help with development (Coding Doubts)
« Reply #11 on: January 27, 2017, 05:38:25 PM »
@Alex_Palomo

This format is OK, ie move towards infinity (at least on my lenses) 1 step (-1) using step size 1.

Best guidance is use true rather than false.

Code: [Select]
lens.focus(-1,1,true)

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #12 on: January 31, 2017, 12:04:02 PM »
Hy guys! I have some problems with the movie.start() LUA function. I just call it when I press "Start Video" on the submenu but it just only goes to LiveView without recording:


I thought that it would be an easy problem to solve, but I don't know why it does not work.
Hope you can help me. Thank you.

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #13 on: February 01, 2017, 05:15:33 PM »
Hy guys!
1. Do you know if I can decide wherever a photo is saved when executing camera.shoot() (LUA Scripting)?
2. Can I read from the SD card (or any memory on the camera) with LUA?
Thank you!

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: Help with development (Coding Doubts)
« Reply #14 on: February 02, 2017, 12:29:18 AM »
1.
Code: [Select]
string.format("DCIM/%03dCANON/%s%04d.CR2", dryos.shooting_card.folder_number, dryos.prefix, dryos.shooting_card.file_number)

2. Use io library: https://www.lua.org/manual/5.3/manual.html#6.8

Trying to read from or write to a CR2 file from Lua may not be the best idea. What are you trying to do?

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #15 on: February 02, 2017, 11:11:47 AM »
Thank you dmilligan!
I just want to (in this order):
1.Take some photos
2.Read them from the SD card and then save them in different variables
3.Once I have the images, then perform some image processing (obviously I need to work with matrices)
4....


garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 2218
Re: Help with development (Coding Doubts)
« Reply #16 on: February 02, 2017, 01:06:22 PM »
@Alex_Palomo

Alex I have PMed you replies several times.

Based on what you say below, I don't see any complications.

Lua will allow you to robustly take an image when you want, ie at a specified exposure or at a specified focus point (as I said to you have a look at others' scripts for ideas).

After that it is simply 'PC-based' post processing, eg reading the image file, either a CR2 or a DNG or even a MLV file, into your PC(/MAC).

Cheers

Garry

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #17 on: February 02, 2017, 05:20:07 PM »
Hy garry23, I will work on it!
Again thank you for your time.

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #18 on: February 02, 2017, 05:23:56 PM »
I'm actually working on the src file focus.c and I need to use two methods:

1. A method to take a photo
2. A method to move the focus (Do LensFocus or LensFocus2 move the focus?)

Which ones do you know?
Thank you.

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 2218
Re: Help with development (Coding Doubts)
« Reply #19 on: February 02, 2017, 05:58:33 PM »
Why are you going to the .c area of ML?

I thought you wanted to script?

If so, read everything here https://davidmilligan.github.io/ml-lua/modules/camera.html#shoot, including the demo scripts.

Cheers

Garry


Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #20 on: February 20, 2017, 05:34:51 PM »
Hy guys!
How can I capture the data on the image buffer? I mean, I need to save the image seen by the sensor on a certain moment. Is that even possible?
Thank you.

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: Help with development (Coding Doubts)
« Reply #21 on: February 20, 2017, 07:09:43 PM »
The "raw backend" (raw.c/.h) has functions for that. For examples see modules/silent/silent.c

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #22 on: March 15, 2017, 06:02:35 PM »
Hy guys! I'm trying to load my own module, but every time I try to load it on the camera it fails and the following occurs:



Before loading the module, the README file is correctly read and displayed on the screen.

Hope you can help me! Thank you!

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 8609
Re: Help with development (Coding Doubts)
« Reply #23 on: March 15, 2017, 06:08:38 PM »
Link to your repository (and therefore source) would be helpful, I think!

Alex_Palomo

  • New to the forum
  • *
  • Posts: 31
  • Audiovisual Systems Engineer and 600D owner.
Re: Help with development (Coding Doubts)
« Reply #24 on: March 15, 2017, 06:18:35 PM »
Link on your PM! Thank you Walter :)