Help with development (Coding Doubts)

Started by Alex_Palomo, January 24, 2017, 04:35:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Alex_Palomo

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

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

Thanks for your time Licaon_Kter!
What is the advantage of using Lua?


dmilligan

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

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:

QuotePANIC: 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

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

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

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

Thank you dfort!!! I'll be updating this post so that to keep you all informed.  :)

Alex_Palomo

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

@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.


lens.focus(-1,1,true)

Alex_Palomo

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

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

1.

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

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

@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

Hy garry23, I will work on it!
Again thank you for your time.

Alex_Palomo

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

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

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

The "raw backend" (raw.c/.h) has functions for that. For examples see modules/silent/silent.c

Alex_Palomo

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

Link to your repository (and therefore source) would be helpful, I think!

Alex_Palomo