Forums > Jitter

datamoshing with cv.jit.otpicalflow and jit.repos

February 4, 2013 | 10:28 am

Hi,

I’m quite new to max/jitter so I hope I’m not asking a dumb question.

I’m working on a patch to emulate a datamoshing effect on realtime with videocam capture. Searching around it seems that a good approach would be to use opticalflow to get the motion of the pixels, then applying this motion to another image. In jitter, this seems to be possible with cv.jit.opticalflow which I managed to output a 2-plane matrix, and then applying this matrix to the right inlet of jit.repos. But the output of jit.repos displays nothing. Not even with a plain JPG as left-input matrix.

This is my first post, so I’m not sure how it works

Any pointers on how to achieve this would be very much appreciated.

Cheers.



dtr
February 4, 2013 | 12:27 pm

It works for me (with a 2nd jit.qt.movie as modulator input ’cause I don’t have a webcam). I changed 2 things though:
- set the qmetro to 40ms for a framerate of 25fps, you have it set at 2ms/500fps (you can also set [qmetro 25 hz] for the same effect)
- set @unique 1 on the modulator jit.qt.movie so I don’t get identical frames, which result in no optical flow. You should be able to set this on your grab object as well. Perhaps you ‘ll need to use [jit.grab] instead of [cv.jit.grab] for that.


February 4, 2013 | 12:47 pm

Thanks for your quick response, dtr.

I did as you suggested, but still no output from the jit.repos. I must be missing something. I had a jit.qt.movie loader, too, but I removed it to post it here. What filetype did you load as modulator? And as target? Could you post your patch to see if it works for me?



dtr
February 4, 2013 | 12:53 pm

Here you go. (I used ‘copy compressed’. That’s the easier way to share patches on the forum. Copy the full blob below or click ‘copy to clipboard’, then File>New from clipboard in Max)

It uses Max’s example video files.

– Pasted Max Patch, click to expand. –


dtr
February 4, 2013 | 12:57 pm

One efficiency thingy: if there’s no specific reason for otherwise, the jit.qt.movies and grabs should be driven from the same qmetro, not individual ones.


February 4, 2013 | 12:59 pm

Got it. Changing the offset mode flag to 1 (spatial map relative offsets) on the jit.repos made the trick.
[jit.repos @mode 1]
Thanks!


Viewing 6 posts - 1 through 6 (of 6 total)