Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$DEFINE SRL_USE_REMOTEINPUT}
- {$I srl/osr.simba}
- function FilterThing(sum, ref: TPointArray; splitdist: Int32): T2DPointArray;
- var
- i,j: Int32;
- refs, clusters: T2DPointArray;
- begin
- clusters := sum.Cluster(splitdist);
- refs := ref.Cluster(splitdist);
- for i:=0 to High(clusters) do
- for j:=0 to High(refs) do
- if clusters[i].Find(refs[j][0]) <> -1 then
- Result += clusters[i];
- end;
- var
- i: Int32;
- sum, pts1, pts2: TPointArray;
- res: T2DPointArray;
- begin
- RSClient.Image.Clear();
- while True do
- begin
- //pts1 contains their red thingy on helment
- srl.FindColors(pts1, CTS2(661879, 11, 0.12, 1.50), MainScreen.Bounds());
- //white body
- srl.FindColors(pts2, CTS2(9475995, 30, 0.12, 0.09), MainScreen.Bounds());
- //get the helmet that is near a white body [within 10px distance]
- //10px because distance to nearest part of body (white helmet part), it's not a long distance
- pts1 := pts1.PointsInRangeOf(pts2, 0, 10);
- //get the body that is near a red helment [within 70px distance]
- //70px because distance from feet to helmet may be large-ish.
- pts2 := pts2.PointsInRangeOf(pts1, 0, 70);
- //combine body and helmet
- sum := pts1 + pts2;
- // magic to filter out shit that is not of part the body and helmet
- // but can still be considered within 70px of the helment.
- res := FilterThing(sum, pts1, 3);
- //draw to RSClient
- RSClient.Image.Clear();
- for i:=0 to High(res) do
- begin
- RSClient.Image.DrawTPA(res[i], 255);
- RSClient.Image.DrawTPA(res[i].ConvexHull().Connect(), $FFFF00);
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement