mbeyeler / opencv-python-blueprints

M. Beyeler (2015). OpenCV with Python Blueprints: Design and develop advanced computer vision projects using OpenCV with Python, Packt Publishing Ltd., ISBN 978-178528269-0.
GNU General Public License v3.0
291 stars 184 forks source link

chapter7 classifiers.py code is not working #2

Closed G10DRAS closed 8 years ago

G10DRAS commented 8 years ago
def recall ()
......
    self.mode = "one-vs-one"

where to set self.mode ? What is the difference between "one-vs-one" and "one-vs-all"

mbeyeler commented 8 years ago

Good catch! This happened when moving from Chapter 6 to Chapter 7... A classifier should either take mode as an input argument in the constructor, or in this case hard-code it to "one-vs-all".

The strategies are explained in the book (Chapter 6): "one-vs-all": The one-vs-all strategy involves training a single classifier per class, with the samples of that class as positive samples and all other samples as negatives. For k classes, this strategy thus requires the training of k classifiers. "one-vs-one": The one-vs-one strategy involves training a single classifier per class pair, with the samples of the first class as positive samples and the samples of the second class as negative samples. For k classes, this strategy requires the training of k*(k-1)/2 classifiers.

I need to fix self.mode and extend documentation.

G10DRAS commented 8 years ago

Thank you for explaination, Michael !! For now I hardcoded the mode. I was experimenting with both the mode, and "one-vs-one" works well for me.

I found another bug, which is related to putTextabove a detected face. x,y co-ordinate are missing in function.

chapter7.py
def _process_frame(self, frame):
........
                # draw label above bounding box
                cv2.putText(frame, str(label), (x, y - 20),
                            cv2.FONT_HERSHEY_COMPLEX, 1, (0, 255, 0), 2)
mbeyeler commented 8 years ago

I created another issue for your reported bug above (see #6).

mbeyeler commented 8 years ago

Closed #2 via 92c92d0e71d09b54ca94e79bd9a69509cdf5e05a.