# This implementation keps failing silently, but the repo readme says it works fine. The controller for my robot keeps crashing when this function is triggered

**URL:** <https://forum.opencv.org/t/this-implementation-keps-failing-silently-but-the-repo-readme-says-it-works-fine-the-controller-for-my-robot-keeps-crashing-when-this-function-is-triggered/24593>\
**Category:** Python\
**Tags:** programming\
**Created:** [June 19, 2026, 7:58am UTC](https://forum.opencv.org/t/this-implementation-keps-failing-silently-but-the-repo-readme-says-it-works-fine-the-controller-for-my-robot-keeps-crashing-when-this-function-is-triggered/24593 "2026-06-19T07:58:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Paul](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/john_paul/32/14322_2.png) [@John\_Paul](https://forum.opencv.org/u/John_Paul)\
**Post date:** [June 19, 2026, 7:58am UTC](https://forum.opencv.org/t/this-implementation-keps-failing-silently-but-the-repo-readme-says-it-works-fine-the-controller-for-my-robot-keeps-crashing-when-this-function-is-triggered/24593/1 "2026-06-19T07:58:47Z")

</div>

```python
def fire_detection(self, verbose=True):
        """
        Detect the smoke and return the fire coordinate in the image
        Parameters:
            verbose (bool): whether to print status messages or not
        Returns:
            coord_fire (list):x,y image coordinates of the fire
        """
        img = self.get_image_from_camera()
        # Segment the image by color in HSV color space
        hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)

        # Range of the smoke
        smoke_lower = np.array([0, 0, 168])
        smoke_upper = np.array([172, 111, 255])

        mask_fire = cv2.inRange(hsv, smoke_lower, smoke_upper)

        fire_ratio = np.round(
            (cv2.countNonZero(mask_fire))/(img.size/3)*100, 2)

        if fire_ratio > 0.15: # Higher the fire ratio, higher the number of fire in the image
            # Detect the contours on the binary image using cv2.CHAIN_APPROX_NONE
            contours, _ = cv2.findContours(
                image=mask_fire, mode=cv2.RETR_TREE, method=cv2.CHAIN_APPROX_NONE)

            # Approximate contours to polygons + get circles
            contours_poly = [None]*len(contours)
            centers = [None]*len(contours)
            radius = [None]*len(contours)
            radius_max = 0
            for i, c in enumerate(contours):
                contours_poly[i] = cv2.approxPolyDP(c, 3, True)
                centers[i], radius[i] = cv2.minEnclosingCircle(
                    contours_poly[i])
                # We keep only the biggest circle and > 3
                if radius[i] > 3 and radius[i] > radius_max:
                    coord_fire = centers[i]
                    radius_max = radius[i]
                    if verbose:
                        print(
                            "fire detected, coordinates {}".format(centers[i]))

            if verbose: # Draw polygonal contour + circles and save the image
                drawing = img.copy()
                for i in range(len(contours)):
                    color = (random.randint(0, 256), random.randint(
                        0, 256), random.randint(0, 256))
                    cv2.drawContours(drawing, contours_poly, i, color)
                    cv2.circle(drawing, (int(centers[i][0]), int(
                        centers[i][1])), int(radius[i]), color, 2)
                cv2.imwrite("fire_detection.jpg", drawing)

            return coord_fire

```

---

<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:** [June 19, 2026, 9:26am UTC](https://forum.opencv.org/t/this-implementation-keps-failing-silently-but-the-repo-readme-says-it-works-fine-the-controller-for-my-robot-keeps-crashing-when-this-function-is-triggered/24593/2 "2026-06-19T09:26:01Z")

</div>

“keeps crashing” you say.

do you have any details?

what have you tried, to debug this, to _get_ information about the crash?
