View Full Version : Grid filter for positioning overlays?
trolltuning
4th February 2005, 16:50
Is there any way some one could make a grid filter for determining coordinates- e.g. positioning overlays?
It seems awkward to have to do this by trial and error.
Manao
4th February 2005, 19:48
function block(int size_x, int size_y)
{
white_block = blankclip(width = size_x - 1, height = size_y - 1, color = $000000, pixel_type = "RGB32")
part_grid_block = white_block.addborders(0,0,1,1, color = $ffffff)
return part_grid_block
}
function line_blocks(int clip_width, int size_x, int size_y)
{
return clip_width <= size_x ? block(size_x, size_y).crop(0,0,clip_width, size_y) \
: stackhorizontal(line_blocks(clip_width - size_x, size_x, size_y), block(size_x, size_y))
}
function rows_lines(int clip_width, int clip_height, int size_x, int size_y)
{
return clip_height <= size_y ? line_blocks(clip_width, size_x, size_y).crop(0,0,clip_width, clip_height) \
: stackvertical(rows_lines(clip_width, clip_height - size_y, size_x, size_y), line_blocks(clip_width, size_x, size_y))
}
grid = rows_lines(640, 480, 16, 16)The grid is in RGB, to show it, overlay it on something.
trolltuning
4th February 2005, 21:14
Thanks that's awesome, and really impressive how fast you wrote that.
stickboy
5th February 2005, 09:52
Originally posted by trolltuning
Is there any way some one could make a grid filter for determining coordinates- e.g. positioning overlays?
It seems awkward to have to do this by trial and error.I copy a frame, paste it into Photoshop, and determine the coordinates from there.
trolltuning
5th February 2005, 13:09
Originally posted by stickboy
I copy a frame, paste it into Photoshop, and determine the coordinates from there.
Ah, didn't know about that as I don't have photoshop. I am in the process of writing a function to add numbers to Manao's grid. I'm sure there is a better way to increase the variable than this?
function addNumbs(last,int q,int r)
{
q=20
subtitle(q.string,q-10,r)
q=q+20
r=r+20
subtitle(q.string,q-10,r)
q=q+20
r=r+20
subtitle(q.string,q-10,r)
q=q+20
r=r+20
subtitle(q.string,q-10,r)
q=q+20
r=r+20
subtitle(q.string,q-10,r)
q=q+20
r=r+20
subtitle(q.string,q-10,r)
q=q+20
r=r+20
subtitle(q.string,q-10,r)
}
Manao
5th February 2005, 13:20
function block2(int size_x, int size_y, int n)
{
white_block = blankclip(width = size_x - 1, height = size_y - 1, color = $000000, pixel_type = "RGB32")
part_grid_block = white_block.addborders(0,0,1,1, color = $ffffff)
number = messageclip(string(n)).converttorgb32()
small_number = number.lanczosresize(width(part_grid_block), height(part_grid_block))
numbered_grid_block = overlay(part_grid_block, small_number, mode = "add")
return numbered_grid_block
}
function line_blocks(int clip_width, int size_x, int size_y, int n)
{
return clip_width <= size_x ? block2(size_x, size_y, n).crop(0,0,clip_width, size_y) \
: stackhorizontal(block2(size_x, size_y, n), line_blocks(clip_width - size_x, size_x, size_y, n + 1))
}
function rows_lines(int clip_width, int clip_height, int size_x, int size_y, int n)
{
next_n = n + ceil(clip_width / size_x)
return clip_height <= size_y ? line_blocks(clip_width, size_x, size_y, n).crop(0,0,clip_width, clip_height) \
: stackvertical(line_blocks(clip_width, size_x, size_y, n), rows_lines(clip_width, clip_height - size_y, size_x, size_y, next_n))
}
source = rows_lines(640, 480, 16, 16, 0)Just a warning : it's very slow to open the script.
trolltuning
5th February 2005, 13:49
@manao
That actually opens in a little over 3 seconds on my AMD 1600.
:)
It displays a different number in each square- I was just trying to display some x and y values.
Manao
5th February 2005, 13:55
function block3(int size_x, int size_y, int x, int y)
{
white_block = blankclip(width = size_x - 1, height = size_y - 1, color = $000000, pixel_type = "RGB32")
part_grid_block = white_block.addborders(0,0,1,1, color = $ffffff)
number = messageclip(string(x) + "," + string(y)).converttorgb32()
small_number = number.lanczosresize(width(part_grid_block), height(part_grid_block))
numbered_grid_block = overlay(part_grid_block, small_number, mode = "add")
return numbered_grid_block
}
function line_blocks(int clip_width, int size_x, int size_y, int x, int y)
{
return clip_width <= size_x ? block3(size_x, size_y, x, y).crop(0,0,clip_width, size_y) \
: stackhorizontal(block3(size_x, size_y, x, y), line_blocks(clip_width - size_x, size_x, size_y, x + 1, y))
}
function rows_lines(int clip_width, int clip_height, int size_x, int size_y, int x, int y)
{
return clip_height <= size_y ? line_blocks(clip_width, size_x, size_y, x, y).crop(0,0,clip_width, clip_height) \
: stackvertical(line_blocks(clip_width, size_x, size_y, x, y), rows_lines(clip_width, clip_height - size_y, size_x, size_y, x, y + 1))
}
source = rows_lines(640, 480, 16, 16, 0, 0)It's becoming real hard to read to number :)
stickboy
5th February 2005, 13:57
Originally posted by trolltuning
Ah, didn't know about that as I don't have photoshop.Surely there are a lot of free image editors that will show coordinates (e.g. Paint Shop Pro on the shareware side, paint.net on the freeware side... a good image editor is always useful. :) Heck, mspaint shows coordinates too.)
trolltuning
5th February 2005, 14:11
Thanks to both of you.
@Manao It's still readable on a 720x480
I get it now -just multiply the numbers by the block size.
@stickboy- I think I had PSP and the trial expired but I'll check out the others.
Didée
5th February 2005, 21:58
Originally posted by stickboy
I copy a frame, paste it into Photoshop, and determine the coordinates from there.
... and probably I have finished my cropping before your application has finished with initializing itself ;)
trolltuning
7th February 2005, 14:36
Originally posted by Didée
... and probably I have finished my cropping before your application has finished with initializing itself ;)
I'm glad Stickboy let me know that paint will show coordinates,
(I stupidly assumed it didn't as that is missing from the photoshop application in the Corel suite I've been using) obviously that's very convenient for a single frame but I still think what Manao wrote for me is useful if I want to get coordinates from a bunch of different frames for use with conditional filter and cropping. Guess I'll know after I play with it for two weeks. :)
trolltuning
11th February 2005, 15:30
OK test results:
I get about 1 FPS which I think is really a comfortable speed to copy down x and y coordinates of different frames.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.