Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 5067212

Browse files
committed
Fix broken python syntax highlighting
1 parent 8925193 commit 5067212

File tree

1 file changed

+7
-7
lines changed
  • content/tutorials/portenta-h7/por-openmv-fd

1 file changed

+7
-7
lines changed

content/tutorials/portenta-h7/por-openmv-fd/content.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import time # Import module for tracking elapsed time
4545

4646
The next step is to calibrate the camera sensor for achieving the best results using the `sensor` module. You can use the `set_contrast()` function to set the contrast of the sensor to its highest value (3). This can help the algorithm identifying lines and edges more easily. `set_gainceiling()` controls the amplification of the signal from the camera sensor including any associated background noise. For maximising the detection success rate it is recommended to set the camera frame size to `HQVGA`.
4747

48-
```python
48+
```py
4949
# Sensor settings
5050
sensor.set_contrast(3)
5151
sensor.set_gainceiling(16)
@@ -59,7 +59,7 @@ OpenMV provides a Haar Cascade class ready to be used with the Vision Shield's c
5959

6060
***Remember: Fewer stages make the detection faster while leading to more false positives.***
6161

62-
```python
62+
```py
6363
face_cascade = image.HaarCascade("frontalface", stages=25)
6464
print(face_cascade) # Prints the Haar Cascade configuration
6565
```
@@ -78,13 +78,13 @@ Download [this file](assets/face.pbm) containing the smiley bitmap and copy it t
7878

7979
Load the image into a variable called `faceImage` using the `Image()` function from the `image` module. The inital slash refers to the root directoy of the flash drive. In order to use the image as an overlay to the camera stream instead of directly displaying it set the `copy_to_fb` to False such that it doesn't get copied into the frame buffer automatically.
8080

81-
```python
81+
```py
8282
faceImage = image.Image("/face.pbm", copy_to_fb=False)
8383
```
8484

8585
Before drawing the image on top of the camera stream you need to figure out the scale ratio to match the detected face size in the camera stream. The provided bitmap image comes in a 128x128 px resolution. You can calculate the correct scale ratio with the following formula:
8686

87-
```python
87+
```py
8888
faceX = boundingBox[0]
8989
faceY = boundingBox[1]
9090
faceWidth = boundingBox[2]
@@ -95,15 +95,15 @@ scale_ratio = faceWidth / faceImage.width()
9595

9696
You can then draw the scaled bitmap image on top of the camera image using the `draw_image` function:
9797

98-
```python
98+
```py
9999
# Draws the bitmap on top of the camera stream
100100
cameraImage.draw_image(faceImage, faceX, faceY, x_scale=scale_ratio, y_scale=scale_ratio)
101101
```
102102

103103
## 7. Uploading the Script
104104
Let's program the Portenta with the complete script and test if the algorithm works. Copy the following script and paste it into the new script file that you created.
105105

106-
```python
106+
```py
107107
import sensor # Import the module for sensor related functions
108108
import image # Import module containing machine vision algorithms
109109
import time # Import module for tracking elapsed time
@@ -161,7 +161,7 @@ In this tutorial you learned how to use OpenMV's built-in face detection algorit
161161
# Next Steps
162162
The [HaarCascade](https://docs.openmv.io/library/omv.image.html#class-Haarcascade-feature-descriptor) class provided by OpenMV can also detect other facial features such as eyes. For example you could tweak your **face_detection.py** script to detect your eyes simply by changing the `path` parameter from `frontalface ` to `eye` which is also a built-in model. Go ahead and replace the following line in your script and try to figure out how to overlay your eyes with a bitmap image of an eye.
163163

164-
```python
164+
```py
165165
face_cascade = image.HaarCascade("eye", stages=25)
166166
```
167167

0 commit comments

Comments
 (0)