digic 6 motion detection (was Re: SX60HS Porting)

  • 87 Replies
  • 20910 Views
digic 6 motion detection (was Re: SX60HS Porting)
« on: 10 / July / 2016, 23:32:56 »
Advertisements
Working on understanding motion_detect.c and adapting to Digic 6.

*

Offline reyalp

  • ******
  • 11082
Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #1 on: 10 / July / 2016, 23:55:25 »
Working on understanding motion_detect.c and adapting to Digic 6.
The main thing you should need to adapt is the YUV decoding in the main loop of md_detect_motion.

You will also need to make sure the various vid_get_viewport.... functions return appropriate values.

To get good md performance, you will need to find a way to determine the current viewport buffer and implement vid_get_viewport_live_fb, but this isn't required to get basic functionality working.

As I mentioned in the other thread, there are issues that need to be resolved over how to support different fb layouts in modules, but you don't have to deal with those right away.
Don't forget what the H stands for.

Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #2 on: 11 / July / 2016, 09:51:28 »
Perhaps there's a better thread to post about motion detect Digic 6 than here? It seems fairly straightforward so far but I find some questionable code ( existing) that might mess up modes other than luminance (Y) mode especially.

*

Offline reyalp

  • ******
  • 11082
Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #3 on: 11 / July / 2016, 13:00:25 »
Perhaps there's a better thread to post about motion detect Digic 6 than here?
Feel free to start a new thread in the development section. Probably a big enough project to warrant it's own thread.
Quote
It seems fairly straightforward so far but I find some questionable code ( existing) that might mess up modes other than luminance (Y) mode especially.
Do you have a pre-d6 camera to test? If not, picking up a cheap used or refurb might be worth it for the time it saves.

Also, you may find it useful to write test code you can run on your PC with viewport buffer dumps.

I wouldn't be too surprised if the non-Y modes had problems.
Don't forget what the H stands for.


Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #4 on: 12 / July / 2016, 20:24:46 »
I'll probably start a thread...
playing with this, I can get well behaved trigger in Y mode (using modified code), BUT..
after a random number of triggers (1-8 shots) it stops responding.

I checked with modified chdkptp liveview, and it confirms that at this point, the active buffer is changed. Live view uses the same logic to get the view, and it just shows a totally dark screen when motion_detect stops triggering so we are processing the wrong buffer at this point and it seems to stay that way for quite awhile (since the camera isn't doing anything much).

So we may be back to square one unless we can find the correct live buffer, or do some hack to force the live buffer back to the first one, or check all the buffers....
If I quickly scanned the buffer candidates, presumably, the dark ones are not live?
ideas?

*

Offline reyalp

  • ******
  • 11082
Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #5 on: 12 / July / 2016, 21:36:26 »
I'll probably start a thread...
playing with this, I can get well behaved trigger in Y mode (using modified code), BUT..
after a random number of triggers (1-8 shots) it stops responding.

I checked with modified chdkptp liveview, and it confirms that at this point, the active buffer is changed. Live view uses the same logic to get the view, and it just shows a totally dark screen when motion_detect stops triggering so we are processing the wrong buffer at this point and it seems to stay that way for quite awhile (since the camera isn't doing anything much).
Probably obvious, but just in case... the physical screen remains on and continues to update when this happens? If the camera goes into power save, I would expect live view to stop updating. (edit: I wouldn't particularly expect it to go black, but not a surprise if it does)

Normally, I'd expect the camera to rotate between 3 (or possibly more) buffers at whatever the live view frame rate is (probably ~30 fps). I would not expect the non-current buffers to be black.

Ram dumping the G7X, I found four buffers that looked like live view, but I didn't determine whether they contain sequential images. I suppose it's possible that there is are three in a triple buffer set and one is used for something else.

On G7X, these buffers start with the one found via "VRAM Address", with 0x2000 between each buffer.

edit:
Split from sx60 thread https://chdk.setepontos.com/index.php?topic=12532.msg129249#msg129249
« Last Edit: 12 / July / 2016, 21:40:08 by reyalp »
Don't forget what the H stands for.

Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #6 on: 12 / July / 2016, 23:14:42 »
The camera doesn't go into power save. Everything looks normal on the LCD , but triggers no longer happen when I pass my hand or finger into the image. And live view chdkptp switches to a dark screen. Have to admit I didn't play much with liveview and chdkptp and actually shooting manually outside of motion detect but I suppose the same thing would happen. 
It would appear that cycling to a new viewport buffer doesn't happen on a schedule but rather when necessary.
I think you should see this on g7x without hacking motion detect.c.


But of course live view mods are necessary.
« Last Edit: 12 / July / 2016, 23:53:29 by 62ndidiot »

Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #7 on: 12 / July / 2016, 23:16:29 »
I'll try to look for buffers and dump them. Might clarify things
I could post the hacked code
Requires viewport byte width in libc
« Last Edit: 12 / July / 2016, 23:18:23 by 62ndidiot »


*

Offline reyalp

  • ******
  • 11082
Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #8 on: 13 / July / 2016, 00:48:25 »
It would appear that cycling to a new viewport buffer doesn't happen on a schedule but rather when necessary.
I would be quite surprised if there weren't frame buffers somewhere that update at the live view frame rate.
Don't forget what the H stands for.

Re: digic 6 motion detection (was Re: SX60HS Porting)
« Reply #9 on: 13 / July / 2016, 12:58:07 »
my bad....improvised debug info log trashed memory. 
can now trigger 20 or more sequential shots with motion detect...
So i'll clean up a bit and post it when I have time...next few days are busy.
Thanks for comments making me look at stuff closer!!