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

35
LINES

< > BotCompany Repo | #468 - Movement detector (monte carlo)

Lua code - Image recognition

get("#380") -- hashImage

w, h = img.width, img.height

function cacheImage()
  cached = {}
  for i = 1, 100 do
    local x, y = math.random(0, w-1), math.random(0, h-1)
    cached[i] = {x, y, img.getInt(x, y)} 
  end
end

function hasMovement()
  for i = 1, #cached do
    local x, y, pix = unpack(cached[i])
    if img.getInt(x, y) ~= pix then
      return true
    end
  end
  return false
end

return function()
  if cached == nil then
    cacheImage()
    return nil -- "Initializing..."
  end
  if hasMovement() then
    cacheImage()
    return "Movement"
  else
    cacheImage() -- optional, but a little safer
    return "Probably no movement"
  end
end

Author comment

Began life as a copy of #467

download  show line numbers   

Travelled to 9 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz

No comments. add comment

Image recognition results

show nils
Image Result Result calculated
#1004090 java.lang.OutOfMemoryError: Java heap space 2016-08-07 13:34:12

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

[raw result]
[visualize]
#1000330 java.lang.OutOfMemoryError: Java heap space 2016-08-01 17:36:25

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

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

[raw result]
[visualize]
#1000320 java.lang.OutOfMemoryError: Java heap space 2016-08-01 15:25:56

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

[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]
#1000241 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 09:35:20

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

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

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

[raw result]
[visualize]
#1000212 java.lang.OutOfMemoryError: Java heap space 2016-08-01 05:29:53

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

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

[raw result]
[visualize]
#1000003 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:56:10

[raw result]
[visualize]
#309 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:56:10

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

[raw result]
[visualize]
#178 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:58

[raw result]
[visualize]
#85 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:58

[raw result]
[visualize]
#145 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:57

[raw result]
[visualize]
#141 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:57

[raw result]
[visualize]
#115 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:57

[raw result]
[visualize]
#84 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:57

[raw result]
[visualize]
#100 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:55

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

[raw result]
[visualize]
#87 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:55

[raw result]
[visualize]
#93 java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operat... 2016-08-01 01:15:55

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

[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: #468
Snippet name: Movement detector (monte carlo)
Eternal ID of this version: #468/1
Text MD5: 9aa7e83b4244252776b13d94c69718c7
Author: stefan
Category:
Type: Lua code - Image recognition
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-02-17 20:55:46
Source code size: 695 bytes / 35 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 996 / 69
Referenced in: [show references]

Formerly at http://tinybrain.de/468 & http://468.tinybrain.de