Browse Source

Version 27.11 ("fertiger" Tracker)

master
David Moeckel 3 weeks ago
parent
commit
c2b5dc7e96
2 changed files with 67 additions and 8 deletions
  1. 26
    6
      .idea/workspace.xml
  2. 41
    2
      src/main/java/Tracker.java

+ 26
- 6
.idea/workspace.xml View File

<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="4d75e996-cee4-4ec6-b802-5b56d0c0eac4" name="Changes" comment="Version 23.11 (Grafics update)">
<list default="true" id="4d75e996-cee4-4ec6-b802-5b56d0c0eac4" name="Changes" comment="Version 27.11">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/GraphicsProgram.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/GraphicsProgram.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/Tracker.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Tracker.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/Tracker.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Tracker.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent"><![CDATA[{
"keyToString": { "keyToString": {
"Application.GTCar.executor": "Run",
"Application.GraphicsProgram.executor": "Run", "Application.GraphicsProgram.executor": "Run",
"Application.Tracker.executor": "Run",
"Downloaded.Files.Path.Enabled": "false", "Downloaded.Files.Path.Enabled": "false",
"Repository.Attach.Annotations": "false", "Repository.Attach.Annotations": "false",
"Repository.Attach.JavaDocs": "false", "Repository.Attach.JavaDocs": "false",
"com.codeium.enabled": "true", "com.codeium.enabled": "true",
"git-widget-placeholder": "master", "git-widget-placeholder": "master",
"kotlin-language-version-configured": "true", "kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/david/Documents/Uni/GTCar/processing-4.3/core/library/core.jar",
"last_opened_file_path": "C:/Users/david/Documents/Uni/GTCar/opencv/build/java/opencv-4100.jar",
"node.js.detected.package.eslint": "true", "node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true", "node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)", "node.js.selected.package.eslint": "(autodetect)",
"vue.rearranger.settings.migration": "true" "vue.rearranger.settings.migration": "true"
} }
}]]></component> }]]></component>
<component name="RunManager">
<configuration name="GTCar" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="Tracker" />
<module name="GTCar_V2_maven" />
<option name="VM_PARAMETERS" value="-Djava.library.path=C:\Users\david\Documents\Uni\GTCar\opencv\build\java\x64" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager"> <component name="TaskManager">
<task active="true" id="Default" summary="Default task"> <task active="true" id="Default" summary="Default task">
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1732108904989</updated> <updated>1732108904989</updated>
<workItem from="1732108906083" duration="758000" /> <workItem from="1732108906083" duration="758000" />
<workItem from="1732113837570" duration="8726000" />
<workItem from="1732113837570" duration="11452000" />
</task> </task>
<task id="LOCAL-00001" summary="First Commit Test"> <task id="LOCAL-00001" summary="First Commit Test">
<option name="closed" value="true" /> <option name="closed" value="true" />
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1732368525826</updated> <updated>1732368525826</updated>
</task> </task>
<option name="localTasksCounter" value="4" />
<task id="LOCAL-00004" summary="Version 27.11">
<option name="closed" value="true" />
<created>1732703104268</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1732703104268</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<MESSAGE value="First Commit Test" /> <MESSAGE value="First Commit Test" />
<MESSAGE value="Version 20.11" /> <MESSAGE value="Version 20.11" />
<MESSAGE value="Version 23.11 (Grafics update)" /> <MESSAGE value="Version 23.11 (Grafics update)" />
<option name="LAST_COMMIT_MESSAGE" value="Version 23.11 (Grafics update)" />
<MESSAGE value="Version 27.11" />
<option name="LAST_COMMIT_MESSAGE" value="Version 27.11" />
</component> </component>
</project> </project>

+ 41
- 2
src/main/java/Tracker.java View File

private final int EXP = -7; // Belichtungszeit (idealerweise: 0) private final int EXP = -7; // Belichtungszeit (idealerweise: 0)
private final int FPS = 60; // FPS private final int FPS = 60; // FPS


private Point currentPosition;
public Tracker(){ public Tracker(){


} }
System.out.println("Fehler: Die Webcam konnte nicht geöffnet werden."); System.out.println("Fehler: Die Webcam konnte nicht geöffnet werden.");
return; return;
} }

Mat frame = new Mat();

while (true){
if (capture.read(frame)){
HighGui.imshow("GTCar", frame);

currentPosition = trackPosition(frame);

if (HighGui.waitKey(1) == 27) {
break;
}
}else{
System.out.println("Fehler: Das Kamerabild konnte nicht gelesen werden.");
break;
}
}


} }


public int getX(){ public int getX(){
return x;
return (int) currentPosition.x;
} }


public int getY(){ public int getY(){
return y;
return (int) currentPosition.y;
} }


public Point getPosition(){
return currentPosition;
}


private Point trackPosition(Mat thresholdFrame) {
// Berechne die Momente des binären Bildes
Moments moments = Imgproc.moments(thresholdFrame);

// Prüfen, ob m00 (Fläche) nicht null ist, um Division durch Null zu vermeiden
if (moments.get_m00() != 0) {
int cx = (int) (moments.get_m10() / moments.get_m00());
int cy = (int) (moments.get_m01() / moments.get_m00());
return new Point(cx, cy);
} else {

return null;
}
}
private VideoCapture setUp() { private VideoCapture setUp() {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME); System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
VideoCapture capture = new VideoCapture(CAM); VideoCapture capture = new VideoCapture(CAM);

Loading…
Cancel
Save