Skip to main content

Posts

Install python and opencv on the raspberry

Setup Conda and Python and opencv Setup venv python -m venv ocv2-env ocv2-env/bin/pip install opencv-python  Try python script import cv2 # Open the default camera cam = cv2.VideoCapture(0) # Get the default frame width and height frame_width = int(cam.get(cv2.CAP_PROP_FRAME_WIDTH)) frame_height = int(cam.get(cv2.CAP_PROP_FRAME_HEIGHT)) # Define the codec and create VideoWriter object fourcc = cv2.VideoWriter_fourcc(*'mp4v') out = cv2.VideoWriter('output.mp4', fourcc, 20.0, (frame_width, frame_height)) while True:     ret, frame = cam.read()     # Write the frame to the output file     out.write(frame)     # Display the captured frame     cv2.imshow('Camera', frame)     # Press 'q' to exit the loop     if cv2.waitKey(1) == ord('q'):         break # Release the capture and writer objects cam.release() out.release() cv2.destr...
Recent posts

Setting up my new raspberry

What did i buy? Raspberry Pi-C 8g vormontiert RASP PI-C 8GB Raspberry Pi-C mit Raspberry Pi 5B 8GB, vormontiert 142.95€ Camera  RASP CAM 2 Raspberry Pi - Kamera, 8MP, 67°, v2 18.95€ Cable to camera needed for raspberry pi-5 Raspberry Pi 5 Kamera Adapterkabel, offizielles Kamera Adapterkabel für Raspberry Pi 5, 300mm 2.35€ Hdmi mini to hdmi cable  Mini-Displayport Kabel, Mini-DP-HDMI, 1080p, 2,0 m Keyboard  Rii i8 Mini Tastatur Wireless 16.99€ the box unpacked connected booting configure What will i configure? Wifi network New user with sudo rights; at configuration menu Setup remote desktop Find my ip nmcli device show IP4.ADDRESS[1]: 192.168.180.111/24 Activate ssh and vnc In raspberry config, activate ssh and vnc. Next install tigervnc and ssh on client PC, and connect to IP address above.    vncviewer 192.168.180.111 user jan

Push image to Docker https registry

 Setup remote https registry docker container stop registry docker container rm -v registry ls /var/lib/ cd mkdir certs cd certs openssl req   -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key   -addext "subjectAltName = DNS:myregistry.jankester.com"   -x509 -days 365 -out certs/domain.crt cd .. openssl req   -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key   -addext "subjectAltName = DNS:myregistry.jankester.com"   -x509 -days 365 -out certs/domain.crt ls -ltr ls cd certificate_authority history | grep import ls -ltr ../ ls -ltr ../certs cd docker run -d   --restart=always   --name registry   -v "$(pwd)"/certs:/certs   -e REGISTRY_HTTP_ADDR=0.0.0.0:5443   -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt   -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key   -p 5443:5443   registry:2 docker container ls history | grep allow sudo ufw al...

Certbot https certificate

 Install https certificate for apache sudo apt install certbot python3-certbot-apache cd /etc/apache2/sites-available/ ls sudo cp 000-default.conf jankester-com.conf sudo vi jankester-com.conf sudo a2ensite jankester-com.conf sudo a2dissite 000-default.conf sudo apache2ctl configtest cd /var/www/ ls ls -l sudo mkdir jankester-com sudo mkdir jankester-com/public_html sudo cp html/* jankester-com/public_html/. sudo apache2ctl configtest sudo systemctl restart apache2 sudo ufw status sudo certbot --apache sudo apt-get install certbot python-certbot-apache sudo apt-get install certbot python3-certbot-apache sudo certbot --apache sudo apt install certbot python3-certbot-apache certbot --version sudo apt install snapd sudo snap install --classic certbot /snap/bin/certbot --version sudo /snap/bin/certbot --apache cd jankester-com/public_html/

Install tileserver

Install Postgis  sudo apt-get install -y postgresql postgis sudo apt-get install -y postgresql-contrib postgresql-12-postgis-3 postgresql-12-postgis-3-scripts sudo service postgresql start locale git --version # to verify whether git is already installed sudo apt-get install -y git sudo apt-get install -y postgresql-contrib postgresql-12-postgis-3 postgresql-12-postgis-3-scripts sudo service postgresql start echo $USER locale -c locale createdb gis --encoding="UTF8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template=template0 sudo -u postgres createuser -s $USER createdb gis --encoding="UTF8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --template=template0 psql -d gis -c 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;' psql -d gis -c "create user jan;grant all privileges on database gis to postgres;" psql -d gis -c "grant all privileges on database gis to postgres;" psql -d g...

Create a groovy console and bind to selenium

Required groovy files In the previous posting we defined the pom file that we need for our build environment. Now we will setup some groovy files to get selenium and groovy running interactively. ConsoleWaiter.groovy The idea of Groovy Console I found on some other sides. Honour goes for instance too: http://josefbetancourt.wordpress.com/tag/eclipse-2/ I copied some code of this, and put it under src/test/groovy/com/jankester/selenium/test/utils: package com.jankester.selenium.test.utils /** * File: ConsoleWaiter.groovy */ import groovy.lang.Binding; import groovy.ui.Console; /** * Provides a wrapper for the console. * * Based on source by John Green * Adapted from: http://www.oehive.org/files/ConsoleWaiter.groovy * Released under the Eclipse Public License * http://www.eclipse.org/legal/epl-v10.html * * I added methods to allow use from Java. * * The run() method launches the console and causes this thread * to sleep until the console's window is closed....

Setting up maven project to do first interactive test

The pom file A basic pom file that sets up all dependencies for your interactive selenium-groovy testing contains following: <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>com.jankester.selenium</groupId> <artifactId>selenium-groovy-public</artifactId> <version>2012.03-SNAPSHOT</version> <packaging>jar</packaging> <name>selenium-groovy</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.selenium.version>2.20.0</project.selenium.version> <log.root>./target</log.root> </properties> <dependencies...

Interactive selenium testing

The problem Location of elements When I started using selenium, I noticed that it is not easy to do it right. First you start with IDE, but you notice, that the IDE does not really record a lot. In a next step I added firebug, and started analyzing how the elements where to be located: either by tag, id, class etc. Junit testcase With this information I could then create my junit testcase: @Test public void testMapView() throws Exception { //assert that we cannot see submenu of MapCreator elem = driver.findElement(By.className(SeleniumConstants.MAP_SUB_MENU)); String style = elem.getAttribute("style"); assertTrue("Element must have style display off.",style.matches("display: none.*")); logger.debug("Located element " + SeleniumConstants.MAP_SUB_MENU); //find menu and click on mapview elem = driver.findElement(By.id(SeleniumConstants.MAP_CONTROL)); actions.moveToElement(elem).click().perform(); //assert su...

Logging in selenium

For some time I am trying to get more out of Selenium. Lot has changed here: selenium2 is a big improvement, and since 2.15 google also contributed its Advanced User Interactions API to the selenium code base, which seems to be a big improvement for mouse handling. To get a better understanding of what is happening, and especially why my test scripts are failing, I wanted to control the logging of my webdriver. I noticed that this was a bit of a pain. Selenium firefox driver is using java.util.logging. So you are bound to the mechanisms that java.util.logging offers you for log configuration. This is the approach I ended up with. Before I startup my Firefox Webdriver, I used the setLogLevel method to set the Level of logging that is used for all driver logs. When you set this to WARNING, all logs that the driver makes, are considered to be WARNING logs, when you set them to FINE, all logs are considered to be FINE logs. So dependent on the settings inside your logging.properties,...