Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed freescal_cup_k22f
source/Camera.cpp@2:804797b0b298, 2015-01-13 (annotated)
- Committer:
- RobinN7
- Date:
- Tue Jan 13 15:50:44 2015 +0000
- Revision:
- 2:804797b0b298
- Parent:
- 0:3af30bfbc3e5
- Child:
- 3:f6a91455109c
passe bas am?lior?;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobinN7 | 0:3af30bfbc3e5 | 1 | #include "mbed.h" |
RobinN7 | 0:3af30bfbc3e5 | 2 | #include "Camera.h" |
RobinN7 | 0:3af30bfbc3e5 | 3 | |
RobinN7 | 0:3af30bfbc3e5 | 4 | DigitalOut clk(PTC2); |
RobinN7 | 0:3af30bfbc3e5 | 5 | DigitalOut si(PTB3); |
RobinN7 | 0:3af30bfbc3e5 | 6 | AnalogIn pix(PTB2); |
RobinN7 | 0:3af30bfbc3e5 | 7 | |
RobinN7 | 0:3af30bfbc3e5 | 8 | |
RobinN7 | 0:3af30bfbc3e5 | 9 | extern unsigned int pixel[128]={0}; // |
RobinN7 | 0:3af30bfbc3e5 | 10 | |
RobinN7 | 0:3af30bfbc3e5 | 11 | void readline(void) // fonction de détection de la ligne |
RobinN7 | 0:3af30bfbc3e5 | 12 | { |
RobinN7 | 0:3af30bfbc3e5 | 13 | clk=0; // la clock est nulle au départ |
RobinN7 | 0:3af30bfbc3e5 | 14 | int compteur = 0,index_pixel = 0, capture_finie = 0; |
RobinN7 | 0:3af30bfbc3e5 | 15 | |
RobinN7 | 0:3af30bfbc3e5 | 16 | while (!capture_finie) |
RobinN7 | 0:3af30bfbc3e5 | 17 | { |
RobinN7 | 0:3af30bfbc3e5 | 18 | if (compteur & 1) // si compteur impair => front descendant |
RobinN7 | 0:3af30bfbc3e5 | 19 | clk = 0; |
RobinN7 | 0:3af30bfbc3e5 | 20 | else // compteur pair => montant |
RobinN7 | 0:3af30bfbc3e5 | 21 | clk = 1; |
RobinN7 | 0:3af30bfbc3e5 | 22 | if(compteur == 5) |
RobinN7 | 0:3af30bfbc3e5 | 23 | si = 1; |
RobinN7 | 0:3af30bfbc3e5 | 24 | |
RobinN7 | 0:3af30bfbc3e5 | 25 | if (compteur == 7) |
RobinN7 | 0:3af30bfbc3e5 | 26 | si=0; |
RobinN7 | 0:3af30bfbc3e5 | 27 | if ( (compteur & 1) && compteur >= 7) { // mesure sur front descendant, |
RobinN7 | 0:3af30bfbc3e5 | 28 | // pc.printf("lecture pixel\n"); |
RobinN7 | 0:3af30bfbc3e5 | 29 | pixel[index_pixel]=pix.read_u16(); |
RobinN7 | 0:3af30bfbc3e5 | 30 | index_pixel ++; |
RobinN7 | 0:3af30bfbc3e5 | 31 | } |
RobinN7 | 0:3af30bfbc3e5 | 32 | wait_us(10); |
RobinN7 | 0:3af30bfbc3e5 | 33 | compteur++; |
RobinN7 | 0:3af30bfbc3e5 | 34 | |
RobinN7 | 0:3af30bfbc3e5 | 35 | if (index_pixel == 128) |
RobinN7 | 0:3af30bfbc3e5 | 36 | capture_finie = 1; |
RobinN7 | 0:3af30bfbc3e5 | 37 | } |
RobinN7 | 0:3af30bfbc3e5 | 38 | wait_ms(1); |
RobinN7 | 0:3af30bfbc3e5 | 39 | } |
RobinN7 | 0:3af30bfbc3e5 | 40 | |
RobinN7 | 0:3af30bfbc3e5 | 41 | void passebas() |
RobinN7 | 0:3af30bfbc3e5 | 42 | { |
RobinN7 | 2:804797b0b298 | 43 | unsigned int tamponpixel[256] ={0}; |
RobinN7 | 0:3af30bfbc3e5 | 44 | int ordre=10, i=0; |
RobinN7 | 0:3af30bfbc3e5 | 45 | |
RobinN7 | 2:804797b0b298 | 46 | // Passe bas en partant de la gauche sur tamponpixel[0:127] |
RobinN7 | 2:804797b0b298 | 47 | for (i=ordre;i<128;i++) |
RobinN7 | 0:3af30bfbc3e5 | 48 | { |
RobinN7 | 0:3af30bfbc3e5 | 49 | for (int a=0;a<ordre;a++) |
RobinN7 | 0:3af30bfbc3e5 | 50 | { |
RobinN7 | 0:3af30bfbc3e5 | 51 | tamponpixel[i]+=pixel[i-a]; |
RobinN7 | 0:3af30bfbc3e5 | 52 | } |
RobinN7 | 0:3af30bfbc3e5 | 53 | tamponpixel[i]/=ordre; |
RobinN7 | 0:3af30bfbc3e5 | 54 | } |
RobinN7 | 0:3af30bfbc3e5 | 55 | |
RobinN7 | 2:804797b0b298 | 56 | // Passe bas en partant de la droite sur tamponpixel[128:255] |
RobinN7 | 0:3af30bfbc3e5 | 57 | for (i=127-ordre;i>=0;i--) |
RobinN7 | 0:3af30bfbc3e5 | 58 | { |
RobinN7 | 0:3af30bfbc3e5 | 59 | for (int a=0;a<ordre;a++) |
RobinN7 | 0:3af30bfbc3e5 | 60 | { |
RobinN7 | 2:804797b0b298 | 61 | tamponpixel[255-i]+=pixel[i+a]; |
RobinN7 | 0:3af30bfbc3e5 | 62 | } |
RobinN7 | 2:804797b0b298 | 63 | tamponpixel[255-i]/=ordre; |
RobinN7 | 0:3af30bfbc3e5 | 64 | } |
RobinN7 | 0:3af30bfbc3e5 | 65 | |
RobinN7 | 0:3af30bfbc3e5 | 66 | // Actualisation de l'image filtrée |
RobinN7 | 0:3af30bfbc3e5 | 67 | for (i=0;i<128;i++) |
RobinN7 | 0:3af30bfbc3e5 | 68 | { |
RobinN7 | 0:3af30bfbc3e5 | 69 | pixel[i]=tamponpixel[i]; |
RobinN7 | 0:3af30bfbc3e5 | 70 | } |
RobinN7 | 0:3af30bfbc3e5 | 71 | } |