Pular para o conteúdo principal

Postagens

Mostrando postagens de abril, 2017

Control Arduino from a JavaFX application

That's exciting. I just finished a post about JArduino and Java and I was supposed to sleep, but I wanted to give it a try with JavaFX, so I did and in less than a minute I could make a first experiment! Show a light sensor information in a label In Control Arduino from Java using JArduino post we printed on console the current light intensity coming from a LDR connected to an arduino. In less than a minute I could add it to a label in a JavaFX application, see:  I basically reused the same class from the other post and read the output in a JavaFX thread (see Platform.runLater on the code below). My plan was to also turn on a LED from the JavaFX application. So let's continue on the original plan. Controlling a LED and reading a LDR In the second version I used a chart to display the LDR sensor data in real time and also used a button to control a LED, so when we turn the LED on we can see the values changing. See our circuit now and notice a LED on di...

Control Arduino from Java using JArduino

In general when we want to integrate Java with Arduino we can use the serial port for interaction, where arduino will receive commands and also write sensors information. This is greatly explained on JavaFX 8: Introduction by Example book on Arduino chapter. The problem with this approach is that you will end having to maintain two distinct codes in two different languages. Another approach is use JArduino , which allows you to write Java code to directly interact with arduino! What you should do is follow the procedure from README file in JArduino page to install the firmware in your arduino board, then build a maven project that has jarduino as a maven dependency to start building Java applications that uses arduino. Since it is Java we can use JavaFX, JavaEE and all the Java APIs! Problems I always start writing before having something working (that's the reason why I had more than 50 draft posts on this blog). So I faced some unwanted issue and I had to figure out a few...

Using tensorflow from a Java application

At this point you probably have heard about TensorFlow , the famous Google library for deep learning. Although the TensorFlow core is C/C++, the most famous API is Python (as you can see in Siraj or sintdex tutorials), but recently TensorFlow released a Java version for the API. TensorFlow has a small tutorial about the Java API and a single more complex example to classify image. On this small tutorial the link to the tensorflow JAR is broken. I found a working JAR in this URL. The upstream tutorial was already corrected as you can see in github . There's also the labeled image example , which is very simple as well, but a few additional steps must be taken: Download the content from this URL and unzip it. It is the labeled dataset Download the LabelImage class from github . When saving it locally remember to remove the package declaration. Having the tensorflow JAR you downloaded previously and the native library, you can compile and run the class passing the direct...