# Best way to check objects on images?

**URL:** <https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615>\
**Category:** Python\
**Tags:** matchtemplate, imgproc, objdetect\
**Created:** [February 17, 2021, 1:14pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615 "2021-02-17T13:14:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zedespook](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/zedespook/32/991_2.png) [@Zedespook](https://forum.opencv.org/u/Zedespook)\
**Post date:** [February 17, 2021, 1:14pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615/1 "2021-02-17T13:14:32Z")

</div>

I know this is very specific, but I would like to hear some ideas on detecting objects on a captured image while the object I desire to detect is on another picture.

**The methods I tried:**

1. **Template Matching** - Seems the most promising, but didn’t detect for me, probably because of the light sources.

2. **Haar Cascades** - Out-of-date, cannot use in OpenCV 4.

3. **Hough Lines** - Didn’t seem effective in my task.

4. **Arithmetic Operations on Images** - Couldn’t check how close the subtracted image was to the original. I still need to find a way.

_I am interested to hear what you have to say. Thank you for reading through this._

Here are the links for all method’s documentation (I can only put 2 links into a post, that’s why I put it into a [Pastebin](https://pastebin.com/ugV6Q3P5)).

---

<div class="post-metadata">

**Author:** ![laurent.berger](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@laurent.berger](https://forum.opencv.org/u/laurent.berger)\
**Post date:** [February 17, 2021, 1:31pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615/2 "2021-02-17T13:31:14Z")

</div>

Hi,  
What is your object?

---

<div class="post-metadata">

**Author:** ![Zedespook](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/zedespook/32/991_2.png) [@Zedespook](https://forum.opencv.org/u/Zedespook)\
**Post date:** [February 17, 2021, 1:34pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615/3 "2021-02-17T13:34:03Z")

</div>

Let’s say a blue piece of paper. The photo taken is just above it and the paper is lying on the surface of the table.

Now, let’s say that I want to detect multiple of these blue papers, but there could be some that are slightly torn, and I don’t want it to detect torn papers.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 17, 2021, 3:53pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615/4 "2021-02-17T15:53:20Z")

</div>

a photo of the situation would be helpful

---

<div class="post-metadata">

**Author:** ![Zedespook](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/zedespook/32/991_2.png) [@Zedespook](https://forum.opencv.org/u/Zedespook)\
**Post date:** [February 17, 2021, 3:56pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615/5 "2021-02-17T15:56:17Z")

</div>

Here is the template image:

 ![reference](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/3/3d99d946ddd3d9c80c3382b23f8b60319bf93d93.jpeg)

---

<div class="post-metadata">

**Author:** ![Zedespook](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/zedespook/32/991_2.png) [@Zedespook](https://forum.opencv.org/u/Zedespook)\
**Post date:** [February 17, 2021, 3:57pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615/6 "2021-02-17T15:57:14Z")

</div>

And here is the camera capture of the image I want the object to be detected on:

 ![test](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/7/72709d9166e6834d3453a528f6038ef3deaf310b.jpeg)

I might add, I played around with the brightness options, and it didn’t help.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 17, 2021, 4:04pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615/7 "2021-02-17T16:04:11Z")

</div>

the picture of the scene is nearly useless for machine vision. insufficient illumination.

that “blue rectangle” is a solar cell including the usual wire strips.

what precise information do you want out of the “detection”?

---

<div class="post-metadata">

**Author:** ![Zedespook](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/zedespook/32/991_2.png) [@Zedespook](https://forum.opencv.org/u/Zedespook)\
**Post date:** [February 17, 2021, 4:47pm UTC](https://forum.opencv.org/t/best-way-to-check-objects-on-images/1615/8 "2021-02-17T16:47:15Z")

</div>

I know what it is, I wanted to give an example of what it might look like hence the phrase “let’s say.” I just want the program to output if the cell is broken or not, like is there a crack, or is it in multiple pieces.
