Commit ee05bd33 authored by Evgeny Kusmenko's avatar Evgeny Kusmenko
Browse files

Merge branch 'adi-dev' into 'master'

Adi dev

See merge request !1
parents f5baf0ce 07445d58
target
nppBackup
.project
.settings
.classpath
.idea
.git
*.iml
# (c) https://github.com/MontiCore/monticore
stages:
- linux
TestJobLinux:
stage: linux
image: registry.git.rwth-aachen.de/monticore/embeddedmontiarc/applications/gans/mnist-infogan/gans_mxnet:latest
script:
- chmod +x build.sh
- ./build.sh
except:
changes:
- README.md
- .gitignore
\ No newline at end of file
File added
cmake_minimum_required(VERSION 3.5)
project (default)
set (CMAKE_CXX_STANDARD 11)
add_subdirectory(target)
add_subdirectory(src/cpp)
<!-- (c) https://github.com/MontiCore/monticore -->
# BallTracking # BallTracking
## Prerequisites
1. Ubuntu Linux 16.04 LTS or 18.04 LTS (experimental)
2. Armadillo (at least armadillo version 6.600 must be used) [Official instructions at Armadillo Website](http://arma.sourceforge.net/download.html).
3. OpenCV.
## How to Run
Generate and build the code for the EMAM model by executing:
```
bash build.sh
```
Finally, run the BallTracking-Video as follows:
```
./build/src/cpp/BallTracking
```
You can try different videos to track a yellow object or object with different color by setting the corresponding values to CVInRange-variables in _BallTracking.cpp_.
\ No newline at end of file
rm -rf target
java -jar embedded-montiarc-math-generator-0.1.16-SNAPSHOT-jar-with-dependencies.jar -m src/main/emam/ -r ba.ballTracking -o target -flag-generate-cmake
cd target
sed -i 's/cube/Cube<unsigned char>/g' ba_ballTracking.h
cd ..
rm -rf build
mkdir build && cd build
echo "Building BallTracking.."
cmake ..
make
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.monticore.lang.monticar.utilities</groupId>
<artifactId>emadllib</artifactId>
<version>1.0-SNAPSHOT</version>
<name>emadllib</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>de.monticore.lang.monticar.utilities</groupId>
<artifactId>maven-streamtest</artifactId>
<version>0.0.5</version>
<configuration>
<pathMain>./src/main/emam</pathMain>
<pathTest>./src/test/emam</pathTest>
<pathTmpOut>./target/tmp</pathTmpOut>
<generator>MinGW</generator>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>streamtest-execute</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
<pluginGroup>de.topobyte</pluginGroup>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>se-nexus</id>
<username>cibuild</username>
<password>${env.cibuild}</password>
</server>
</servers>
<mirrors>
<mirror>
<id>se-nexus</id>
<mirrorOf>external:*</mirrorOf>
<url>https://nexus.se.rwth-aachen.de/content/groups/public</url>
</mirror>
<mirror>
<id>icm-repository</id>
<mirrorOf>icm</mirrorOf>
<url>http://maven.icm.edu.pl/artifactory/repo/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
https://metric.se.rwth-aachen.de
</sonar.host.url>
<sonar.login>
jenkins
</sonar.login>
<sonar.password>
${env.sonar}
</sonar.password>
</properties>
</profile>
<profile>
<id>se-nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled /></releases>
<snapshots><enabled /></snapshots>
</repository>
<repository>
<id>icm</id>
<url>http://maven.icm.edu.pl/artifactory/repo/</url>
<releases><enabled /></releases>
<snapshots><enabled /></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled /></releases>
<snapshots><enabled /></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>se-nexus</activeProfile>
</activeProfiles>
</settings>
#include "ba_ballTracking.h"
#include "ConvHelper.h"
#include <opencv2/highgui/highgui.hpp>
#include <armadillo>
using namespace arma;
using std::string;
int main(int argc, const char** argv) {
string filename = "BallTrack.mp4";
cv::VideoCapture capture(filename);
cv::Mat frame;
if (!capture.isOpened()) {
throw "Error when trying to read BallTrack.mp4";
}
ba_ballTracking ballT_Object;
ballT_Object.init();
//GaussianBlur
ballT_Object.sizeXIn = 11;
ballT_Object.sizeYIn = 11;
ballT_Object.sigmaXIn = 0;
ballT_Object.sigmaYIn = 0;
//CvtColor
ballT_Object.colorConversionIn = 40;
//InRange
ballT_Object.lowerBoundaryIn = { 20, 100, 100 };
ballT_Object.upperBoundaryIn = { 30, 255, 255 };
//Erode
ballT_Object.erosion_elemIn = 0;
ballT_Object.iterationsIn1 = 2;
//Dilate
ballT_Object.dilation_elemIn = 0;
ballT_Object.iterationsIn2 = 2;
//FindContours
ballT_Object.modeIn = 0;
ballT_Object.methodIn = 2;
//rectangle
ballT_Object.colorIn = { 0,0,0 };
ballT_Object.thicknessIn = 4;
ballT_Object.lineTypeIn = 4;
cv::namedWindow("w", 1);
for ( ; ; ) {
capture >> frame;
if (frame.empty())
break;
ballT_Object.imageIn = to_armaCube<unsigned char, 3>(frame);
ballT_Object.execute();
cv::Mat output_frame = to_cvmat<unsigned char>(ballT_Object.modImageOut);
// cv::flip(output_frame, output_frame, 0);
//video.write(output_frame);
cv::imshow("w", output_frame);
cv::waitKey(30);
}
cv::waitKey(0);
}
cmake_minimum_required(VERSION 3.5)
project(BallTracking CXX)
set(CMAKE_CXX_STANDARD 11)
add_executable(BallTracking BallTracking.cpp)
set_target_properties(BallTracking PROPERTIES LINKER_LANGUAGE CXX)
find_package(OpenCV REQUIRED)
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
set(LIBS ${LIBS} ${OpenCV_LIBS})
target_include_directories(BallTracking PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(BallTracking ba_ballTracking ${LIBS} -lblas -lopenblas)
export(TARGETS BallTracking FILE BallTracking.cmake)
/* (c) https://github.com/MontiCore/monticore */
package ba;
component BallTracking{
port
in Q^{960,720,3} imageIn,
//GaussianBlur ports
in Z sizeXIn,
in Z sizeYIn,
in Q sigmaXIn,
in Q sigmaYIn,
//CvtColor ports
in Z colorConversionIn,
//InRange ports
in Q^{3} lowerBoundaryIn,
in Q^{3} upperBoundaryIn,
//Erode ports
in Z erosion_elemIn,
in Z iterationsIn1,
//Dilate ports
in Z dilation_elemIn,
in Z iterationsIn2,
//FindContours ports
in Z modeIn,
in Z methodIn,
//RectAngle ports
in Q^{3} colorIn,
in Z thicknessIn,
in Z lineTypeIn,
// i want to input the image again
out Q^{960,720,3} modImageOut;
instance CVGaussianBlur<960,720> gaussBlur;
instance CVCvtColor<960,720> cvtColor;
instance CVInRange<960,720> inRange;
instance CVErode<960,720> erode;
instance CVDilate<960,720> dilate;
instance CVFindContours<960,720> findContours;
instance CVLargestContour largestContour;
instance CVBoundingRect boundingRect;
instance CVRectangle<960,720> rectAngle;
//GaussianBlur
connect imageIn -> gaussBlur.src;
connect sizeXIn -> gaussBlur.sizeX;
connect sizeYIn -> gaussBlur.sizeY;
connect sigmaXIn -> gaussBlur.sigmaX;
connect sigmaYIn -> gaussBlur.sigmaY;
connect gaussBlur.dst -> cvtColor.src;
//CvtColor
connect colorConversionIn -> cvtColor.colorConversion;
connect cvtColor.dst -> inRange.src;
//InRange
connect lowerBoundaryIn -> inRange.lowerBoundary;
connect upperBoundaryIn -> inRange.upperBoundary;
connect inRange.dst -> erode.src;
//Erode
connect erosion_elemIn -> erode.erosion_elem;
connect iterationsIn1 -> erode.iterations;
connect erode.dst -> dilate.src;
//dilate
connect dilation_elemIn -> dilate.dilation_elem;
connect iterationsIn2 -> dilate.iterations;
connect dilate.dst -> findContours.image;
//FindContours
connect modeIn -> findContours.mode;
connect methodIn -> findContours.method;
connect findContours.contours -> largestContour.contours;
//LargestContour
connect largestContour.lContour -> boundingRect.contour;
//BoundingRect
connect boundingRect.rect -> rectAngle.rect;
//CVRectAngle
connect imageIn -> rectAngle.src;
connect colorIn -> rectAngle.color;
connect thicknessIn -> rectAngle.thickness;
connect lineTypeIn -> rectAngle.lineType;
//how to connect the src Image here as input
connect rectAngle.outputImg -> modImageOut;
}
\ No newline at end of file
package ba;
component CVBoundingRect {
port
in Q contour,
out Q rect;
implementation Math {
rect = boundingRect(contour);
}
}
\ No newline at end of file
package ba;
component CVCvtColor<N n =960,N m=720> {
port
in Q^{n,m,3} src,
in Z colorConversion,
out Q^{n,m,3} dst;
implementation Math{
dst = cvtColor(src, colorConversion);
}
}
\ No newline at end of file
package ba;
component CVDilate<N n=960,N m=720> {
port
in Q^{n,m} src,
in Z dilation_elem,
in Z iterations,
out Q^{n,m} dst;
implementation Math{
dst = dilate(src, dilation_elem, iterations);
}
}
\ No newline at end of file
package ba;
component CVErode<N n=960,N m=720> {
port
in Q^{n,m} src,
in Z erosion_elem,
in Z iterations,
out Q^{n,m} dst;
implementation Math{
dst = erode(src, erosion_elem, iterations);
}
}
\ No newline at end of file
package ba;
component CVFindContours<N n=960,N m=720> {
port
in Q^{n,m} image,
in Z mode,
in Z method,
out Q contours;
implementation Math {
contours = findContours(image, mode, method);
}
}
\ No newline at end of file
package ba;
component CVGaussianBlur<N n=960,N m=720> {
port
in Q^{n,m,3} src,
in Z sizeX,
in Z sizeY,
in Q sigmaX,
in Q sigmaY,
out Q^{n,m,3} dst;
implementation Math {
dst = gaussianBlur(src, sizeX, sizeY, sigmaX, sigmaY);
}
}
\ No newline at end of file
package ba;
component CVInRange<N n=960,N m=720> {
port
in Q^{n,m,3} src,
in Q^{3} lowerBoundary,
in Q^{3} upperBoundary,
out Q^{n,m} dst;
implementation Math{
dst = inRange(src, lowerBoundary, upperBoundary);
}
}
package ba;
component CVLargestContour{
port
in Q contours,
out Q lContour;
implementation Math{
lContour = largestContour(contours);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment