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

54
LINES

< > BotCompany Repo | #334 // Vertical Signature

Lua code - Image recognition

brightnessThreshold = 0.9
maxSignatureLen = 10

function rgb(i)
  local r = bit32.band(bit32.rshift(i, 16), 255)
    local g = bit32.band(bit32.rshift(i, 8), 255)
    local b = bit32.band(i, 255)
  return r, g, b
end

function bright(r, g, b)
  return (r+g+b)/(255*3)
end

-- from Java class "SegmentCounter"

function countSegments(y, flip)
  local lastPix = 1
  local segments = 0
  for x = 0, (flip and h or w)-1 do
    local pix = bright(rgb(flip and img.getInt(y, x) or img.getInt(x, y)))
    if pix >= brightnessThreshold and lastPix < brightnessThreshold then
      segments = segments+1
    end
    lastPix = pix
  end
  if lastPix < brightnessThreshold then segments = segments+1 end
  return segments
end

function getSegmentSignature(flip)
  local s = ""
  
  local lastN = 0
  for y = 0, (flip and w or h)-1 do
    local n = math.min(countSegments(y, flip), 9)
    if n ~= lastN then
      if #s >= maxSignatureLen then return nil end
      s = s..n
    end
    lastN = n
  end
  if lastN == 0 and #s > 0 then
    s = s:sub(1, #s-1)
  end
  return s
end

w, h = img.width, img.height

sig = getSegmentSignature(false)
if sig then
  return "Vertical signature: "..sig
end

download  show line numbers   

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

Comments [hide]

ID Author/Program Comment Date
457 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
brightnessThreshold = 0.9
maxSignatureLen = 10

function rgb(i)
local r = bit32.band(bit32.rshift(i, 16), 255)
local g = bit32.band(bit32.rshift(i, 8), 255)
local b = bit32.band(i, 255)
return r, g, b
end

function bright(r, g, b)
return (r+g+b)/(255*3)
end

-- from Java class "SegmentCounter"

function countSegments(y, flip)
local lastPix = 1
local segments = 0
for x = 0, (flip and h or w)-1 do
local pix = bright(rgb(flip and img.getInt(y, x) or img.getInt(x, y)))
if pix >= brightnessThreshold and lastPix < brightnessThreshold then
segments = segments+1
end
lastPix = pix
end
if lastPix < brightnessThreshold then segments = segments+1 end
return segments
end

function getSegmentSignature(flip)
local s = ""

local lastN = 0
for y = 0, (flip and w or h)-1 do
local n = math.min(countSegments(y, flip), 9)
if n ~= lastN then
if #s >= maxSignatureLen then return nil end
s = s..n
end
lastN = n
end
if lastN == 0 and #s > 0 then
s = s:sub(1, #s-1)
end
return s
end

w, h = img.width, img.height

sig = getSegmentSignature(false)
if sig then
return "Vertical signature: "..sig
end
}}
2015-08-18 15:51:24  delete 
455 #1000604 (pitcher) 2015-08-18 00:07:22

add comment

Image recognition results

show nils
Image Result Result calculated
#1000197 Vertical signature: 23212 2016-08-07 20:46:50
Lua instructions: 50465k (5058 ms)

[raw result]
[visualize]
#1000225 Vertical signature: 1 2016-08-05 17:37:13
Lua instructions: 714k (82 ms)

[raw result]
[visualize]
#1004060 java.lang.OutOfMemoryError: Java heap space 2016-08-05 13:07:19

[raw result]
[visualize]
#1000063 Vertical signature: 212 2016-08-04 06:37:52
Lua instructions: 413k (46 ms)

[raw result]
[visualize]
#1000072 Vertical signature: 1212 2016-08-03 15:47:49
Lua instructions: 639k (64 ms)

[raw result]
[visualize]
#1000199 Vertical signature: 1 2016-08-03 09:16:56
Lua instructions: 167180k (16865 ms)

[raw result]
[visualize]
#1000015 Vertical signature: 8979532 2016-08-03 00:51:46
Lua instructions: 162k (17 ms)

[raw result]
[visualize]
#1000613 Vertical signature: 1 2016-08-01 20:24:31
Lua instructions: 57788k (5720 ms)

[raw result]
[visualize]
#1000614 Vertical signature: 1 2016-08-01 20:24:25
Lua instructions: 57788k (5662 ms)

[raw result]
[visualize]
#1000421 Vertical signature: 12592101 2016-08-01 18:09:06
Lua instructions: 49705k (4952 ms)

[raw result]
[visualize]
#1000336 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 17:48:38

[raw result]
[visualize]
#1000335 Vertical signature: 1 2016-08-01 17:45:29
Lua instructions: 13269k (1342 ms)

[raw result]
[visualize]
#1000334 Vertical signature: 1 2016-08-01 17:43:40
Lua instructions: 2293k (238 ms)

[raw result]
[visualize]
#1000330 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 17:37:02

[raw result]
[visualize]
#1000327 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 16:53:47

[raw result]
[visualize]
#1000326 java.lang.OutOfMemoryError: Java heap space 2016-08-01 16:53:18

[raw result]
[visualize]
#1000325 Vertical signature: 1 2016-08-01 16:42:25
Lua instructions: 2125k (215 ms)

[raw result]
[visualize]
#1000310 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 14:21:21

[raw result]
[visualize]
#1000309 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 14:20:52

[raw result]
[visualize]
#1000301 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 14:20:50

[raw result]
[visualize]
#1000294 Vertical signature: 31010391 2016-08-01 14:20:46
Lua instructions: 457k (122 ms)

[raw result]
[visualize]
#1000279 Vertical signature: 1 2016-08-01 13:46:20
Lua instructions: 6939k (772 ms)

[raw result]
[visualize]
#1000267 Vertical signature: 9141479141 2016-08-01 12:45:45
Lua instructions: 1031k (108 ms)

[raw result]
[visualize]
#1000257 Vertical signature: 1 2016-08-01 11:45:08
Lua instructions: 14452k (1521 ms)

[raw result]
[visualize]
#1000241 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 09:35:20

[raw result]
[visualize]
#1000240 Vertical signature: 159431 2016-08-01 09:33:51
Lua instructions: 2202k (299 ms)

[raw result]
[visualize]
#1000236 Vertical signature: 1921 2016-08-01 09:20:47
Lua instructions: 41899k (4154 ms)

[raw result]
[visualize]
#1000194 Vertical signature: 1 2016-08-01 08:41:16
Lua instructions: 48920k (4898 ms)

[raw result]
[visualize]
#509 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 08:39:43

[raw result]
[visualize]
#500 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 08:34:29

[raw result]
[visualize]
#499 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 08:34:28

[raw result]
[visualize]
#1000226 Vertical signature: 1 2016-08-01 08:27:52
Lua instructions: 1959k (286 ms)

[raw result]
[visualize]
#1000227 Vertical signature: 1 2016-08-01 08:27:51
Lua instructions: 185k (21 ms)

[raw result]
[visualize]
#1000224 Vertical signature: 21 2016-08-01 08:23:12
Lua instructions: 12k (3 ms)

[raw result]
[visualize]
#1000223 Vertical signature: 12 2016-08-01 08:23:11
Lua instructions: 12k (24 ms)

[raw result]
[visualize]
#1000222 Vertical signature: 1 2016-08-01 08:22:46
Lua instructions: 1952k (201 ms)

[raw result]
[visualize]
#1000210 Vertical signature: 1 2016-08-01 08:22:24
Lua instructions: 107688k (10689 ms)

[raw result]
[visualize]
#1000221 Vertical signature: 1 2016-08-01 08:22:13
Lua instructions: 38095k (3806 ms)

[raw result]
[visualize]
#1000220 Vertical signature: 1 2016-08-01 08:22:13
Lua instructions: 2402k (321 ms)

[raw result]
[visualize]
#1000216 Vertical signature: 121 2016-08-01 08:22:09
Lua instructions: 192317k

[raw result]
[visualize]
#1000217 Vertical signature: 121 2016-08-01 08:21:18
Lua instructions: 6596k (759 ms)

[raw result]
[visualize]
#1000209 Vertical signature: 121 2016-08-01 08:21:17
Lua instructions: 20711k (2093 ms)

[raw result]
[visualize]
#1000203 Vertical signature: 12321 2016-08-01 08:21:15
Lua instructions: 8542k (920 ms)

[raw result]
[visualize]
#1000215 Vertical signature: 121 2016-08-01 08:21:15
Lua instructions: 2333k (257 ms)

[raw result]
[visualize]
#1000204 Vertical signature: 1271 2016-08-01 08:20:43
Lua instructions: 17936k (1870 ms)

[raw result]
[visualize]
#1000198 Vertical signature: 121 2016-08-01 08:20:42
Lua instructions: 17562k (1823 ms)

[raw result]
[visualize]
#1000196 Vertical signature: 1 2016-08-01 08:20:40
Lua instructions: 188054k

[raw result]
[visualize]
#1000213 Vertical signature: 1 2016-08-01 08:19:39
Lua instructions: 7063k (781 ms)

[raw result]
[visualize]
#1000207 Vertical signature: 1 2016-08-01 08:19:39
Lua instructions: 2005k (289 ms)

[raw result]
[visualize]
#1000208 Vertical signature: 1 2016-08-01 08:19:35
Lua instructions: 7102k (795 ms)

[raw result]
[visualize]
#488 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 08:19:35

[raw result]
[visualize]
#1000212 java.lang.OutOfMemoryError: Java heap space 2016-08-01 08:19:35

[raw result]
[visualize]
#1000200 Vertical signature: 1 2016-08-01 08:19:34
Lua instructions: 14679k (1497 ms)

[raw result]
[visualize]
#1000201 Vertical signature: 1 2016-08-01 08:19:34
Lua instructions: 4335k (453 ms)

[raw result]
[visualize]
#1000202 Vertical signature: 1 2016-08-01 08:19:32
Lua instructions: 16937k (1868 ms)

[raw result]
[visualize]
#1000205 Vertical signature: 1 2016-08-01 08:19:31
Lua instructions: 188054k

[raw result]
[visualize]
#1000218 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 08:19:31

[raw result]
[visualize]
#1000186 Vertical signature: 391 2016-08-01 03:04:16
Lua instructions: 69k (8 ms)

[raw result]
[visualize]
#1000185 Vertical signature: 1549 2016-08-01 03:04:14
Lua instructions: 25k (3 ms)

[raw result]
[visualize]
#1000184 Vertical signature: 2327981 2016-08-01 02:54:47
Lua instructions: 32k (45 ms)

[raw result]
[visualize]
#1000183 Vertical signature: 124379898 2016-08-01 02:54:47
Lua instructions: 28k (7 ms)

[raw result]
[visualize]
#1000182 Vertical signature: 291 2016-08-01 02:54:43
Lua instructions: 38k (50 ms)

[raw result]
[visualize]
#1000181 Vertical signature: 13498 2016-08-01 02:54:26
Lua instructions: 26k (31 ms)

[raw result]
[visualize]
#1000171 Vertical signature: 91 2016-08-01 01:48:41
Lua instructions: 1467k (152 ms)

[raw result]
[visualize]
#1000164 Vertical signature: 1 2016-08-01 01:06:45
Lua instructions: 60k (74 ms)

[raw result]
[visualize]
#1000163 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 00:53:36

[raw result]
[visualize]
#1000162 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 23:21:19

[raw result]
[visualize]
#1000159 Vertical signature: 121212321 2016-07-31 23:12:21
Lua instructions: 482k (49 ms)

[raw result]
[visualize]
#1000128 Vertical signature: 1 2016-07-31 20:21:26
Lua instructions: 8k (18 ms)

[raw result]
[visualize]
#1000129 Vertical signature: 1 2016-07-31 20:21:26
Lua instructions: 8k (12 ms)

[raw result]
[visualize]
#1000126 Vertical signature: 1 2016-07-31 20:13:09
Lua instructions: 12285k (1314 ms)

[raw result]
[visualize]
#419 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 20:02:18

[raw result]
[visualize]
#1000120 Vertical signature: 989 2016-07-31 20:01:21
Lua instructions: 44k (5 ms)

[raw result]
[visualize]
#1000114 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:54:14

[raw result]
[visualize]
#1000117 Vertical signature: 1 2016-07-31 19:54:06
Lua instructions: 11k (27 ms)

[raw result]
[visualize]
#1000116 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:54:02

[raw result]
[visualize]
#1000111 Vertical signature: 121 2016-07-31 19:49:07
Lua instructions: 29k (44 ms)

[raw result]
[visualize]
#1000110 Vertical signature: 1214645 2016-07-31 19:49:06
Lua instructions: 99k (11 ms)

[raw result]
[visualize]
#1000109 Vertical signature: 12121 2016-07-31 19:48:57
Lua instructions: 57k (6 ms)

[raw result]
[visualize]
#1000097 Vertical signature: 21 2016-07-31 19:46:17
Lua instructions: 40k (5 ms)

[raw result]
[visualize]
#1000099 Vertical signature: 1264976978 2016-07-31 19:46:17
Lua instructions: 35k (51 ms)

[raw result]
[visualize]
#362 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:45:39

[raw result]
[visualize]
#1000090 Vertical signature: 1287932121 2016-07-31 19:44:46
Lua instructions: 1177k (130 ms)

[raw result]
[visualize]
#1000088 Vertical signature: 1287932121 2016-07-31 19:44:45
Lua instructions: 1177k (124 ms)

[raw result]
[visualize]
#1000086 Vertical signature: 5971 2016-07-31 19:44:43
Lua instructions: 2322k (308 ms)

[raw result]
[visualize]
#1000085 Vertical signature: 1598 2016-07-31 19:44:41
Lua instructions: 1795k (263 ms)

[raw result]
[visualize]
#1000084 Vertical signature: 1797 2016-07-31 19:44:34
Lua instructions: 1296k (131 ms)

[raw result]
[visualize]
#1000083 Vertical signature: 9 2016-07-31 19:44:27
Lua instructions: 1014k (107 ms)

[raw result]
[visualize]
#1000082 Vertical signature: 292 2016-07-31 19:44:21
Lua instructions: 4091k (448 ms)

[raw result]
[visualize]
#1000081 Vertical signature: 191 2016-07-31 19:43:54
Lua instructions: 2744k (343 ms)

[raw result]
[visualize]
#1000080 Vertical signature: 9121 2016-07-31 19:43:52
Lua instructions: 2903k (293 ms)

[raw result]
[visualize]
#1000079 Vertical signature: 951095 2016-07-31 19:43:50
Lua instructions: 4592k (463 ms)

[raw result]
[visualize]
#1000078 Vertical signature: 982 2016-07-31 19:43:43
Lua instructions: 804k (184 ms)

[raw result]
[visualize]
#1000077 Vertical signature: 21985989 2016-07-31 19:43:37
Lua instructions: 261k (96 ms)

[raw result]
[visualize]
#1000003 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#201 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#183 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#182 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#178 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#145 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#141 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#115 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#113 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#112 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#100 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#98 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#93 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#92 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#91 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#90 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#87 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#85 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#84 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#49 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#48 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:31

[raw result]
[visualize]
#1000014 Vertical signature: 26791 2016-07-31 19:43:29
Lua instructions: 146k (15 ms)

[raw result]
[visualize]
#1000020 Vertical signature: 1 2016-07-31 19:43:28
Lua instructions: 4962k (494 ms)

[raw result]
[visualize]
#1000018 Vertical signature: 1 2016-07-31 19:43:28
Lua instructions: 1742k (179 ms)

[raw result]
[visualize]
#1000021 Vertical signature: 91 2016-07-31 19:43:27
Lua instructions: 257k (27 ms)

[raw result]
[visualize]
#1000045 Vertical signature: 14589873 2016-07-31 19:43:22
Lua instructions: 49355k (4935 ms)

[raw result]
[visualize]
#1000076 Vertical signature: 212 2016-07-31 19:43:12
Lua instructions: 588k (131 ms)

[raw result]
[visualize]
#1000075 Vertical signature: 212 2016-07-31 19:43:12
Lua instructions: 559k (134 ms)

[raw result]
[visualize]
#1000074 Vertical signature: 121 2016-07-31 19:43:12
Lua instructions: 520k (53 ms)

[raw result]
[visualize]
#1000073 Vertical signature: 12121 2016-07-31 19:43:12
Lua instructions: 500k (127 ms)

[raw result]
[visualize]
#1000064 Vertical signature: 121 2016-07-31 19:43:12
Lua instructions: 413k (114 ms)

[raw result]
[visualize]
#1000062 Vertical signature: 12121 2016-07-31 19:43:12
Lua instructions: 412k (107 ms)

[raw result]
[visualize]
#1000061 Vertical signature: 1212 2016-07-31 19:43:12
Lua instructions: 589k (132 ms)

[raw result]
[visualize]
#1000056 Vertical signature: 212 2016-07-31 19:43:12
Lua instructions: 483k (50 ms)

[raw result]
[visualize]
#1000053 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:12

[raw result]
[visualize]
#309 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 19:43:12

[raw result]
[visualize]
#1000219 java.lang.OutOfMemoryError: Java heap space 2016-07-31 18:51:39

[raw result]
[visualize]
#1003745 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 18:51:23

[raw result]
[visualize]
#489 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-07-31 18:51:22

[raw result]
[visualize]

Snippet ID: #334
Snippet name: Vertical Signature
Eternal ID of this version: #334/1
Text MD5: 6f66a82062026fc2017bef94e022aa47
Author: stefan
Category:
Type: Lua code - Image recognition
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-01-24 18:33:25
Source code size: 1235 bytes / 54 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 2020 / 302
Referenced in: [show references]