ByteDeco — JavaC, Apache NiFi, OpenCV, JPEG
If you wish to add a web camera image to your stream in real-time, you can download by NiFi processor to your NiFi 1.2.4 or NiFi 2.0.0-M1 server in the lib directory and restart it.
Then add the processor to the canvas, when executed it will output a JPG.
The only parameter is imagefilename which is optional and defaulted.
NiFi Processor For Apache NiFi 1.24
If you wish to enhance the processor you can download the source and use IntelliJ. You can add things from other libraries or just use Java/OpenCV items like Face Detection and DNN. You can run local tests thanks to NiFi’s TestRunner as shown below.
NiFi Processor Testing with org.apache.nifi.util.TestRunner
private TestRunner testRunner;
@Before
public void init() {
testRunner = TestRunners.newTestRunner(GetWebCameraProcessor.class);
}
@Test
public void testProcessor() {
testRunner.setProperty("imagefilename", "initialimag343434.jpg");
testRunner.setValidateExpressionUsage(true);
testRunner.run();
testRunner.assertValid();
List<MockFlowFile> successFiles = testRunner.getFlowFilesForRelationship(GetWebCameraProcessor.REL_SUCCESS);
System.out.println("SF:" + successFiles.size());
In a simple example I take the image and upload it to Slack. We can also apply various LLM and Deep Learning models against it to do computer vision things such as segmentation.
If you haven’t set up a Slack bot it’s pretty easy.
See:
It is very easy to now send that image to S3 or encode it to send against a REST endpoint such as Cloudera Machine Learning, Azure ML, Amazon ML or Google ML.