Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit 2fa36e5

Browse files
authored
Merge pull request #31 from wml-frc/CJ-Patch
Updated readme for raspbian
2 parents f659514 + 7626e0c commit 2fa36e5

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,41 +101,64 @@ After the basics are complete you can use some of the provided processing types
101101

102102
CJ::VisionTracking vision;
103103

104+
double offsetX, offsetY;
104105
int ResWidth = 640, ResHeight = 480;
105106

106107
double cx, cy;
107108

108109
cv::Mat Image; // Origin Image
109-
cv::Mat ProcessingOutput; // Image in processing
110110
cv::Mat TrackingImage; // Imaged After it has been procesed
111+
cv::Mat ProcessingOutput;
111112

112113
void curtin_frc_vision::run() {
114+
auto inst = nt::NetworkTableInstance::GetDefault();
115+
auto visionTable = inst.GetTable("VisionTracking");
116+
auto table = visionTable->GetSubTable("Target");
113117

114-
vision.SetupVision(&Image, 1, 60, ResHeight, ResWidth, 30, "TestCam", false);
115-
vision.CustomTrack(&TrackingImage, &Image, 30, 70, 50, 255, 50, 2, 2);
116-
vision.Processing.visionHullGeneration.BoundingBox(&TrackingImage, &ProcessingOutput, &cx, &cy, 10);
118+
TargetX = table->GetEntry("Target_X");
119+
TargetY = table->GetEntry("Target_Y");
120+
ImageHeight = table->GetEntry("ImageHeight");
121+
ImageWidth = table->GetEntry("ImageWidth");
117122

118-
#ifdef __DESKTOP__
123+
inst.StartClientTeam(4788);
124+
125+
vision.SetupVision(&Image, 0, 30, ResHeight, ResWidth, 1, "Turret Cam", true);
126+
vision.CustomTrack(&TrackingImage, &Image, 30, 70, 0, 255, 0, 0);
127+
vision.Processing.visionHullGeneration.BoundingBox(&TrackingImage, &ProcessingOutput, &cx, &cy, 10);
128+
#ifdef __DESKTOP__
119129
std::cout << "Exposure Might be dissabled on local machine" << std::endl;
120130
#else
121-
system("v4l2-ctl -d /dev/video4 --set-ctrl=exposure_absolute=1");
131+
system("v4l2-ctl -d /dev/video0 --set-ctrl=exposure_absolute=1");
122132
#endif
123133

134+
std::cout << "Vision Tracking Process Running" << std::endl;
124135
while (true) {
125136
if (vision.Camera.cam.sink.GrabFrame(Image) != 0) {
137+
126138
// Vision Outputing
127139
#ifdef __DESKTOP__
128140
vision.Output.Display("Origin Image", &Image);
129141
vision.Output.Display("Green Filtered Image", &TrackingImage);
130142
vision.Output.Display("Contour Detection", &ProcessingOutput);
131143
#else
132-
vision.Camera.cam.output.PutFrame(Image);
144+
vision.Camera.cam.output.PutFrame(ProcessingOutput); // Might get rid of this to speed up loop.
133145
#endif
146+
147+
//Calc offset
148+
offsetX = cx-(ResWidth/2);
149+
offsetY = cy-(ResHeight/2);
150+
151+
TargetX.SetDouble(offsetX);
152+
TargetY.SetDouble(offsetY);
153+
ImageHeight.SetDouble(ResHeight);
154+
ImageWidth.SetDouble(ResWidth);
155+
} else {
156+
visionTable->PutBoolean("Vision Active", false);
134157
}
135158
}
136159
}
137160
```
138-
The above tracks green pixles at a regular exposure then detects and draws bounding boxes on everything that is green. It then sends the center values through network tables. So you can use it on your roborio and shuffleboard for autonomous.
161+
The above tracks green pixles at a low exposure then detects and draws bounding boxes on everything that is green. It then sends the center values through network tables. So you can use it on your roborio and shuffleboard for autonomous/teleop.
139162
140163
141164
# Getting started with your coprocessor
@@ -144,6 +167,7 @@ The above tracks green pixles at a regular exposure then detects and draws bound
144167
- [Raspberry Pi](https://downloads.raspberrypi.org/raspbian_lite_latest)
145168
### 2. Flash the image onto a microsd card using etcher: https://etcher.io/
146169
- You will need to grab the .img file from the zip. The .img file is what you give to etcher.
170+
- If you want a headless setup. (Only power and ethernet) By Default since 2016, rasbian locks ssh when you first boot onto it. You can unlock ssh by placing a file called ssh with no file extension in the accessible partition of the sd. When the board boots up it should search for this file and allow ssh.
147171
- After complete, insert the microSD card and startup the coprocessor. It may take a minute or two
148172
### 3. SSH into the Coprocessor
149173
- On Mac/Linux, use `ssh username@hostname`

0 commit comments

Comments
 (0)