Previously, I performed object detection using OpenCV, but how much difference is there in accuracy because there is a library named Selective Search? I tried to compare.
Also, previously I tried another method after reviewing the environment construction that I didn't understand very much. So it's a little different.
In addition, when I tried it, Selective Search does not work properly because the function is different in Python3.
Selective Search
I tried using Selective search as R-CNN
# | OS/software/Library | version |
---|---|---|
1 | Mac OS X | EI Capitan |
2 | Python | 2.7 series |
3 | OpenCV | 3.2 system |
4 | Selective Search | |
5 | matplotlib | 2.0 series |
brew update
tap
brew tap homebrew/python
brew tap homebrew/science
brew install python
which python
/usr/local/bin/python ※1
.zshrc
if [ -d $(brew --prefix)/lib/python2.7/site-packages ];then
export PYTHONPATH=$(brew --prefix)/lib/python2.7/site-packages:$PYTHONPAT
fi
python
Python 2.7.13 (default, Apr 4 2017, 08:46:44)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Different from here
brew linkapps
easy_install pip
pip install --upgrade setuptools
pip install --upgrade pip
pip install opencv-python
pip install numpy
pip install matplotlib
pip install selectivesearch
This time I will use this steak set meal. Use Previous as the source code for comparing object detection.
I tried using Selective search as R-CNN is used as it is.
grouping_image.py
import cv2
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import selectivesearch
def main():
# loading lena image
img = cv2.imread("{Image path}")
# perform selective search
img_lbl, regions = selectivesearch.selective_search(
img, scale=500, sigma=0.9, min_size=10)
candidates = set()
for r in regions:
# excluding same rectangle (with different segments)
if r['rect'] in candidates:
continue
# excluding regions smaller than 2000 pixels
if r['size'] < 2000:
continue
# distorted rects
x, y, w, h = r['rect']
if w / h > 1.2 or h / w > 1.2:
continue
candidates.add(r['rect'])
# draw rectangles on the original image
fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(6, 6))
ax.imshow(img)
for x, y, w, h in candidates:
print(x, y, w, h)
rect = mpatches.Rectangle(
(x, y), w, h, fill=False, edgecolor='red', linewidth=1)
ax.add_patch(rect)
cv2.imwrite('{Directory path}' + str(x) + '.jpg', img[y:y + h, x:x + w])
plt.show()
if __name__ == "__main__":
main()
Compare how many dishes, foods and seasonings can be contoured. As for the level, I'm strict about it because it can be extracted for one bowl or plate.
Two
5
--Selective Search was more accurate. ――Even in Selective Search, the meat was not detected cleanly even though it was a steak set meal.
――Is it doing various processing? Selective Search took some speed (about 10 seconds?). ――The functions are quite different depending on the version of Python or OpenCV, which is troublesome. ――I don't feel like I can write Python or OpenCV from scratch in spite of doing various things.
-I tried object detection using Python and OpenCV -I tried to sort out objects from the image of steak set meal-① Object detection -I tried to sort out the objects from the image of the steak set meal-② Overlap number sorting -I tried to sort out the objects from the image of the steak set meal-③ Similar image heat map detection -I tried to sort out the objects from the image of the steak set meal-④ Clustering -I tried to sort out objects from the image of steak set meal-⑤ Similar image feature point detection edition
Recommended Posts