Advertisement
jayadamsmorgan

MedianFilterForDepthSensor.cpp

Apr 21st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. unsigned char n;
  2. const char depthPin = A0;
  3.  
  4. using namespace std;
  5.  
  6. void setup() {
  7.     pinMode(depthPin, INPUT);
  8. }
  9.  
  10. char medianFilter() {
  11.     int depthArray[50];
  12.     for(int a = 0; a != 50; a++) {
  13.         depthArray[a] = analogRead(depthPin);
  14.     }
  15.  
  16.     for(int i=0; i<n; ++i)
  17.     for(int j=i+1; j<n; ++j)
  18.     if(depthArray[j]<depthArray[i])swap(depthArray[i],depthArray[j]);
  19.    
  20.     return depthArray[24];
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement