Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #313 // Crop Visualizer

Lua code - Visualizer

1  
i, j, x1, y1, x2, y2 = string.find(result, "(%d+),%s*(%d+),%s*(%d+),%s*(%d+)")
2  
3  
-- copy image
4  
5  
w, h = img.width, img.height
6  
pixels = {}
7  
for y = 0, h-1 do
8  
  for x = 0, w-1 do
9  
    pixels[y*w+x+1] = img.getInt(x, y)
10  
  end
11  
end
12  
13  
-- paint rectangle
14  
15  
x1, y1 = x1-1, y1-1 -- paint AROUND the found image
16  
17  
for y = y1, y2 do
18  
  pixels[y*w+x1+1] = 0xFF0000
19  
  pixels[y*w+x2+1] = 0xFF0000
20  
end
21  
22  
for x = x1, x2 do
23  
  pixels[y1*w+x+1] = 0xFF0000
24  
  pixels[y2*w+x+1] = 0xFF0000
25  
end

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Image recognition results

Recognizer Recognition Result Visualize Recalc
#308 477 [visualize]

Snippet ID: #313
Snippet name: Crop Visualizer
Eternal ID of this version: #313/1
Text MD5: ec9498c91293b27306e2fdb8fd8cc477
Author: meetup1
Category: ir result visualizers
Type: Lua code - Visualizer
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-02-03 21:26:09
Source code size: 487 bytes / 25 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 1036 / 186
Referenced in: [show references]