Question: I have to find out automatically coordinates (only one point) where border (object) begin, I do not know how to handle function findContours.

[testImage.jpg](https://i.stack.imgur.com/w00QS.jpg)

```

image = cv2.imread("testImage.jpg")

gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Threshold
ret, thresh = cv2.threshold(gray,225,255,0)

# Contours
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

# Here are coordinates that I have to find out
coord = contours[0][1]

# Coordinates to point
point = (coord[0][0],coord[0][1])

# Draw circle on coordinates
cv2.circle(image,point,10,(0,255,0),1)

cv2.imshow("Image", image)
cv2.waitKey()
cv2.destroyAllWindows() 

```

[Output](https://i.stack.imgur.com/79Kfx.jpg)

And my goal is find out coordinates anywhere on the border (blue line) - see last image.

[Goal](https://i.stack.imgur.com/i4x5X.png)

Thanks.

Answer: 
It would be better to create a new css class and toggle with button click. Below would change the `backgroundColor` of the `menuBtn`.

```js
const menuBtn = document.getElementById("menuBtn");

menuBtn.addEventListener("click", changeColor);

function changeColor() {
  menuBtn.classList.toggle("bgColorOrange");
}
```

```css
#menuBtn {
  position: fixed;
  display: block;
  cursor: pointer;
  right: 65px;
  top: 35px;
  z-index: 2;
  cursor: pointer;
}

#menuBtn div {
  width: 38px;
  height: 5px;
  background-color: #EF6A6A;
  margin: 8px;
  border-radius: 2100px;
  transition: all 0.3s ease;
}

.bgColorOrange {
  background-color: #EF6A6A;
}
```

```html
<div id="menuBtn">
  <div class="line1"></div>
  <div class="line2"></div>
  <div class="line3"></div>
</div>
```

If you want to add background color white of lines when `menuBtn` background color is `#EF6A6A`. You can again create a new class and toggle on click of a button.

```js
const menuBtn = document.getElementById("menuBtn");
const lines = document.querySelectorAll(".line");

menuBtn.addEventListener("click", changeColor);

function changeColor() {
  menuBtn.classList.toggle("bgColorOrange");
  lines.forEach(line => line.classList.toggle("bgColorWhite"));
}
```

```css
#menuBtn {
  position: fixed;
  display: block;
  cursor: pointer;
  right: 65px;
  top: 35px;
  z-index: 2;
  cursor: pointer;
}

#menuBtn div {
  width: 38px;
  height: 5px;
  background-color: #EF6A6A;
  margin: 8px;
  border-radius: 2100px;
  transition: all 0.3s ease;
}

.bgColorOrange{
  background-color: #EF6A6A;
}

.bgColorWhite{
  background: white !important;
}
```

```html
<div id="menuBtn">
  <div class="line1 line"></div>
  <div class="line2 line"></div>
  <div class="line3 line"></div>
</div>
```
The issue is that you are referencing your function `changeColor`, which doesn't have a property `style.backgroundColor`. You'll want to make sure you're referencing your DOM element:

```
const element = document.getElementById("menuBtn")
element.onclick = changeColor;

function changeColor() {
    if (element.style.backgroundColor === rgb(0,0,0)) {
        element.style.backgroundColor = rgb(3,2,1)
    } else {
        element.style.backgroundColor = rgb(0,0,0)
    }
}

```

I've also fixed your selector tag.