Blade-Runner-Esque Image Analyzer

Started by TheJBurger, Wed 17/12/2008 02:29:47

Previous topic - Next topic

TheJBurger

I want to get some kind of mouse function going that has the properties to analyze an image. For example, holding down left click would start a selection rectangle from your initial mouse.x, mouse.y, and then to your current mouse coordinates. Afterwards, the game would detect if the rectangle you made overlapped the appropriate item and then it would feed you information.

What I can't figure out is how to do the selection rectangle, and how to detect objects/hotspots in that selection. I tried fumbling about with RawDraw but got unintentional results. Any help would be appreciated.

Gilbert

#1
For the rectangle part I've mucked up a dirty example on how to implement this.
Get this and compile it with V3.1.1RC2+ (since installers are evil for this office computer, I've to wait for the non-installer version of the final before I use it here).

Just check the added codes in the global script (namely, the variable declarations, the CreateRectangleSprite() and the codes added in repeatedly_execute() ). The codes are ugly and need cleaning for general use.

For the detection part, I think one method is to check what is on each pixel inside the rectangle (by the GetXXXAt() functions maybe).

Edit: Whoopsy! Uploaded wrong file. Fixed.

Shane 'ProgZmax' Stevens

Well, if you want to take it easy on yourself, you can have the detection set for hotspots only and do a GetHotspotAt(x,y) with an inclusive check inside the rectangle.  Since you mentioned blade runner I'm guessing you want some kind of interactive video display, right?  Hotspots would work great for this, though perhaps less so if you want to be able to do this on regular game screens.  The nice thing about it is you can make a separate room for each display (it's a bit wasteful but easier on you) with a new image that had the hotspots with valuable information.  This is presuming you want something similar to the zoom in examination in the Blade Runner game, which I thought was pretty cool.  Of course, with any of the GetAt functions, you'll get success no matter which part of the item you hit, which is why hotspots might be more to your taste since you can make a small area  (say on the hand of a person in the image) and make the rest of him another hotspot so you can get different data depending on where you focus.

Gilbert

I'm bored, so I make it to include detection of stuff.

Yes, it is dirty and uncommented. Hope it may inspire you.

BTW, you can press ESC to turn off that listbox before dragging again.

SSH

Errr, why wouldn't someone just select the whole area?
12

Khris

Heh, I almost posted something about that before. I'll do it now then ;)
Each hotspot would need center, size and maybe aspect ratio data that has to be met by the selection with a certain precision.

Alternatively, one could determine how many pixels within the rectangle are within a certain hotspot and e.g. count it as a hit if more than 70% of the area is said hotspot.

TheJBurger

Wow, works great Gilbot. It does inspire me, but I couldn't figure out how to make one on my own from scratch for the life of me.

Instead of a listbox popping up, I was thinking of just having a Display(); command giving you information on the object contained, and if two objects were contained in the selection, it would go null from too much information. Also, if the selection rectangle reached a size so big (say, a 1/4 of a screen, or even smaller) it would go null from too much information and demand a smaller size.

Gilbert

Yeah. The listbox is just something to check whether the stuff are detected correctly.
You can do whatever you want to fix your own need.

SMF spam blocked by CleanTalk