flat assembler
Message board for the users of flat assembler.
Index
> Windows > image search library? |
Author |
|
donn 07 Aug 2020, 21:58
opencv? That's what Sikuli uses, which can recognize objects on the screen. Not sure how much opencv provides off the bat, but it's been around a while.
Links: |
|||
07 Aug 2020, 21:58 |
|
Ali.Z 08 Aug 2020, 19:44
thank you donn, it seems i have to use this library to code my own image recognition.
which is not really what i want, and this library (openCV) is quite large so finding the functions requires is hard. _________________ Asm For Wise Humans |
|||
08 Aug 2020, 19:44 |
|
bitRAKE 09 Aug 2020, 19:16
In the past, I've used a hash of a small block to quickly scan a region. In this case, the image data was constant - exactly RGB values - just needed to find the position. Another case was more complex because of transparent overlays. Yet, I was still able to construct a hash that worked in a fuzzy way based on rough hue calculation. It used a 4x4 array of 2x2 pixels, but only some of the outer groups needed to match.
|
|||
09 Aug 2020, 19:16 |
|
Ali.Z 09 Aug 2020, 19:51
if the pixels (in my case) had fixed RGB values then it might easier to do GetPixel function in a loop, however in my case pixels have dynamically applied gray scale so that is not an easy thing to me as i have absolutely no idea how to implement this that is why i was searching and asking for pre-made dll for these stuff.
also 4x4 if relatively small grid. _________________ Asm For Wise Humans |
|||
09 Aug 2020, 19:51 |
|
bitRAKE 09 Aug 2020, 20:35
I scanned the whole screen, 4x4 (actually 8x8, because of 2x2 pre-processing) is just the size to identify an object on the screen. In a single pass, I could identify a large number of objects. Grayscale doesn't matter when matching only the hue. Sorry, I can't share any code of this project, but it did work quite well.
_________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
09 Aug 2020, 20:35 |
|
donn 10 Aug 2020, 16:16
I looked at OpenCV, and yes I was lost also. May be possible to define your own image recognition by scanning grid regions as you were just discussing.
If you give up, OpenCV seems like it can solve the problem, however. There are some tutorials you can look up. Depending on what kind of tolerances you are looking for, things can get overcomplicated quickly. References: -https://circuitdigest.com/tutorial/object-detection-using-python-opencv -https://www.docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html -https://www.elliotlaketoday.com/ (stop sign image comes from here) I made some slight modifications to the first link above and tested it works. Code: import cv2 import numpy as np image=cv2.imread('image.jpg') cv2.imshow('image',image) cv2.waitKey(0) gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) template=cv2.imread('image_subset.jpg',0) #template=cv2.imread('image_subset2.jpg',0) #result of template matching of object over an image result=cv2.matchTemplate(gray,template,cv2.TM_CCOEFF) sin_val, max_val, min_loc, max_loc=cv2.minMaxLoc(result) top_left=max_loc #increasing the size of bounding rectangle by 50 pixels bottom_right=(top_left[0]+171,top_left[1]+151) cv2.rectangle(image, top_left, bottom_right, (0,255,0),5) cv2.imshow('object found',image) cv2.waitKey(0) cv2.destroyAllWindows() Key function is matchTemplate.
|
|||||||||||||||||||||||||||||
10 Aug 2020, 16:16 |
|
donn 10 Aug 2020, 16:18
Alternate template to search for. Could only attach 3 files per post.
|
||||||||||
10 Aug 2020, 16:18 |
|
Ali.Z 12 Aug 2020, 00:22
thank you, i will convert this to assembly and post the results as soon as i finish other things.
_________________ Asm For Wise Humans |
|||
12 Aug 2020, 00:22 |
|
Ali.Z 13 Aug 2020, 09:20
so i downloaded opencv library, and found that "opencv_world440.dll" is what i need.
i found these functions from export section of the dll: cvCvtColor cvDestroyAllWindows cvMatchTemplate cvMinMaxLoc cvRectangle cvWaitKey however there is no "imread", i also searched other DLLs included in the package but non of them contain that image loading function. not sure if it resides in the static library that meant to be linked (.lib file) and if so then i have to give it a try using C language. (the only language i know other than x86asm.) _________________ Asm For Wise Humans |
|||
13 Aug 2020, 09:20 |
|
donn 13 Aug 2020, 18:17
I think imread is the C++ function name. The C functions include:
Code: C: IplImage* cvLoadImage(const char* filename, int iscolor=CV_LOAD_IMAGE_COLOR ) See a lot of posts talking about converting to grayscale, so this may be acceptable: Code: CV_LOAD_IMAGE_GRAYSCALE - If set, always convert image to the grayscale one References:
- https://github.com/opencv/opencv/blob/master/modules/highgui/include/opencv2/highgui.hpp#L147 I've seen comments in their source discussing differences in the C and C++ APIs, and have seen imread used in the cv namespace. Not sure exactly where each is defined yet. |
|||
13 Aug 2020, 18:17 |
|
Ali.Z 14 Aug 2020, 01:16
donn wrote: C and C++ APIs you are right, honestly i did not know there is different APIs for C and C++. at first i downloaded the wrong library, which is the 4.4.0 which is the C++ one. https://opencv.org/releases/ the one i needed is 3.4.11 (C API), and their release page said absolutely nothing about it. and yes, it have all the functions needed. so i will start testing. _________________ Asm For Wise Humans |
|||
14 Aug 2020, 01:16 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.