Skip to content

Commit

Permalink
ignore very small regions (48x48) when trying harder to identify a vi…
Browse files Browse the repository at this point in the history
…deo region

git-svn-id: https://xpra.org/svn/Xpra/trunk@8404 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jan 6, 2015
1 parent ebef86b commit 91121d2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/xpra/server/video_subregion.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def few_damage_events(event_types, event_count):
if h>=MIN_H:
hc.setdefault(h, dict()).setdefault(y, set()).add(r)

def score_region(info, region):
def score_region(info, region, ignore_size=0):
#check if the region given is a good candidate, and if so we use it
#clamp it:
region.width = min(ww, region.width)
Expand All @@ -218,6 +218,9 @@ def score_region(info, region):
incount += inregion.width*inregion.height*int(count)
outregions = r.substract_rect(region)
for x in outregions:
if ignore_size>0 and x.width*x.height<ignore_size:
#skip small region outside rectangle
continue
outcount += x.width*x.height*int(count)
total = incount+outcount
assert total>0
Expand Down Expand Up @@ -286,7 +289,7 @@ def score_region(info, region):
sslog("vertical regions of width %i at %i with at least %i hits: %s", w, x, min_count, keep)
if keep:
merged = merge_all(keep)
scores[merged] = score_region("vertical", merged)
scores[merged] = score_region("vertical", merged, 48*48)
for h, d in hc.items():
for y,regions in d.items():
if len(regions)>=2:
Expand All @@ -296,7 +299,7 @@ def score_region(info, region):
sslog("horizontal regions of height %i at %i with at least %i hits: %s", h, y, min_count, keep)
if keep:
merged = merge_all(keep)
scores[merged] = score_region("horizontal", merged)
scores[merged] = score_region("horizontal", merged, 48*48)

sslog("merged regions scores: %s", scores)
highscore = max(scores.values())
Expand All @@ -322,6 +325,6 @@ def score_region(info, region):
merged = merge_all(damage_count.keys())
score = score_region("merged", merged)
if score>=110:
return setnewregion(merged, "merged all regions, score=%s", score)
return setnewregion(merged, "merged all regions, score=%s", score, 48*48)

self.novideoregion("failed to identify a video region")

0 comments on commit 91121d2

Please sign in to comment.