Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Video Editing/Mangling

Reply
 
Thread Tools Display Modes
Old 11-06-2018, 10:35 AM   #1
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,684
Default Getting individual pixels (via gfx_evalrect() -- edited title)

I would like to suggest a function to the video-processor, that allows me to actually get the content of a frame/input.
Sometimes, I would love to compare the actual content of two frames on a pixel-level.
One such example would be tracking objects, analysing the content of a picture, finding out, if a video needs to be stabilized.
So I would love to get a 2-d-array, which holds the actual frame as bitmap with individual pixels to work with, as well as being able to blit this array again.

So for that, I would love to ask for the function:

image_array = gfx_get_image(input) - where image_array is an array of the like:
image_array[x][y][r] - red-color-value
image_array[x][y][g] - green-color-value
image_array[x][y][b] - blue-color-value
image_array[x][y][a] - alpha-color-value


This is based on the question about ability to compare two video-items, from this thread: https://forum.cockos.com/showthread....21#post2054521
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 11-07-2018, 03:55 PM   #2
wwwmaze
Human being with feelings
 
Join Date: Oct 2009
Posts: 115
Default

Quote:
Originally Posted by mespotine View Post
Sometimes, I would love to compare the actual content of two frames on a pixel-level.
This is already possible using gfx_evalrect():

From the docs:
Quote:
gfx_evalrect(x,y,w,h,code_string[,flags,src2])

processes a rectangle with code_string being executed for every pixel/pixel-group. code should reference, depending on colorspace: RGBA: r/g/b/a, YUY2: y1,y2,u,v, YV12: y1-y4, u, v.
Values are 0-255, and are not clamped.
set flags|=1 in order to prevent multiprocessing (if your routine needs to process pixels in-order;
side-note: variables _1-_99 are thread-local variables which will always be initialized to 0, and _0 will be initialized to the thread index (0 or 1 usually)).
set flags|=2 to ignore output (analysis-only).
if src2 specified, sr/sg/sb/sa, sy1/su/sv etc will be available to read.
In this case only the intersection of valid rectangles between src2 and the destination buffer will be valid.
Example:
Code:
//Pixel blend
//@param 1:byp "bypass?" 0 0 1 0 1
//@param 3:mode "mode (1=add 2=sub)" 1 1 2 1.5 1
//@param 5:plotCode "plot code?" 0 0 1 0 1

curX=0;
function m(msg) local(s,h,id) (
  id = match("%s",msg) ? "%s" : msg|0===msg ? "%d" : "%f";
  sprintf(s=#,id, msg);
  gfx_str_measure(s,0,h);
  gfx_set(1,1,1,1);
  gfx_str_draw(s,0,curX);
  curX+=h;
);


in1=0;
in2=1;

lcolorspace=colorspace;
colorspace='RGBA';
gfx_blit(in1);

op=mode==1 ? "+" : "-";
sprintf(#code,
"
r=min(255,max(0,r%ssr));
g=min(255,max(0,g%ssg));
b=min(255,max(0,b%ssb));
a=1;
",
op,op,op,op);


!byp ? gfx_evalrect(0,0,project_w,project_h,#code,1,in2);

plotCode ? (
  gfx_set(0.15);
  gfx_fillrect(0,0,project_w*0.4,project_h);
  m(#code);
);

colorspace=lcolorspace;
wwwmaze is offline   Reply With Quote
Old 11-09-2018, 05:27 AM   #3
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,684
Default

Thanks, good to hear that
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.