Skip to content

Commit

Permalink
Improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
KlemenDEV committed Aug 21, 2014
1 parent af71bf2 commit 70ff53e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
46 changes: 36 additions & 10 deletions src/com/muhavision/control/DroneController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class DroneController {

ARDrone drone = null;
NavData data = null;

BufferedImage quadImage = null;

public DroneController(final VisualRenderer visual) {
System.out.println("Drone controller loading...");
Expand All @@ -33,16 +35,7 @@ public DroneController(final VisualRenderer visual) {

@Override
public void imageReceived(BufferedImage image) {
QuadrantFlowSpeed speed = null;
EulerAngles angle = null;

if (visual.global_main.flightMode.getMode() == FlightMode.eMode.MUHA_MODE)
speed = calc.getFlowData(image);
else if (visual.global_main.flightMode.getMode() == FlightMode.eMode.TAG_MODE)
angle = MarkerControl
.getControlDataAndPictureDataBasedOnNavData(data);

visual.reloadDatas(image, speed, data, angle);
quadImage = image;
}
});

Expand All @@ -53,6 +46,39 @@ public void navDataReceived(NavData fdata) {
data = fdata;
}
});

Thread t = new Thread(){

public void run(){
while(true){

long millis = System.currentTimeMillis();

QuadrantFlowSpeed speed = null;
EulerAngles angle = null;

if(visual.global_main.flightMode!=null)
if (visual.global_main.flightMode.getMode() == FlightMode.eMode.MUHA_MODE)
speed = calc.getFlowData(quadImage);
else if (visual.global_main.flightMode.getMode() == FlightMode.eMode.TAG_MODE)
angle = MarkerControl
.getControlDataAndPictureDataBasedOnNavData(data);

visual.reloadDatas(quadImage, speed, data, angle);

millis = System.currentTimeMillis() - millis;

try {
Thread.sleep(70-millis);
} catch (InterruptedException e) {
e.printStackTrace();
}

}
}

};
t.start();

} catch (UnknownHostException e) {
e.printStackTrace();
Expand Down
1 change: 0 additions & 1 deletion src/com/muhavision/control/FlightMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public eMode getMode() {

public void setMode(eMode mode) {
this.mode = mode;
mode.toString();
}

}
27 changes: 14 additions & 13 deletions src/com/muhavision/control/MarkerControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ public class MarkerControl {
public static EulerAngles getControlDataAndPictureDataBasedOnNavData(
NavData nav) {

if (nav.isVisionEnabled()) {
List<VisionTag> tags = nav.getVisionTags();
if (!tags.isEmpty()) {
VisionTag tag = tags.get(0);
if (tag != null) {
EulerAngles angles = new EulerAngles();
Point point = tag.getPosition();
angles.picX = point.getX();
angles.picY = point.getY();
angles.dist = tag.getDistance();
angles.hasAngles = true;
return angles;
if(nav!=null)
if (nav.isVisionEnabled()) {
List<VisionTag> tags = nav.getVisionTags();
if (!tags.isEmpty()) {
VisionTag tag = tags.get(0);
if (tag != null) {
EulerAngles angles = new EulerAngles();
Point point = tag.getPosition();
angles.picX = point.getX();
angles.picY = point.getY();
angles.dist = tag.getDistance();
angles.hasAngles = true;
return angles;
}
}
}
}

return new EulerAngles();
}
Expand Down
4 changes: 0 additions & 4 deletions src/com/muhavision/cv/OpticalFlowCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ public BufferedImage Equalize(BufferedImage bufferedimg) {

IplImage srcimg = AbstractIplImage.create(iploriginal.width(),
iploriginal.height(), IPL_DEPTH_8U, 1);
// IplImage destimg = IplImage.create(iploriginal.width(),
// iploriginal.height(), IPL_DEPTH_8U, 1);

cvCvtColor(iploriginal, srcimg, CV_BGR2GRAY);

// cvEqualizeHist( srcimg, destimg );

BufferedImage eqimg = srcimg.getBufferedImage();

return eqimg;
Expand Down
2 changes: 1 addition & 1 deletion src/com/muhavision/cv/image/VisualRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void paintComponent(Graphics g_panel) {
g.drawString("Mark. dist.: " + angles.dist, 250, 38);
g.fillRect(angles.picX, angles.picY, 4, 4);
}

g.drawString("Roll: " + (int) global_main.roll, 30, 30);
g.drawString("Pitch: " + (int) global_main.pitch, 30, 38);
g.drawString("Yaw: " + (int) global_main.yaw, 30, 46);
Expand Down

0 comments on commit 70ff53e

Please sign in to comment.