Creating a local webserver for opencv image processing on the tk1

I was looking around and I couldn’t find anything that could walk me through how to install a webserver on the jetson tk1. I did look into http://elinux.org/RPi_webserver however I was unsure if I could just do the same on the tk1 as shown in the tutorial.

Here’s the overview of what I would like to do.

  1. Access jetson on lan using a web browser.
  2. User gives image through web browser to jetson server
  3. Jetson server spits back output image to user.

You’ll probably need more storage, e.g., boot to a SATA drive or large SD card, depending on server.

Jetson on L4T uses standard ubuntu administration, see:
https://help.ubuntu.com/14.04/index.html

Although the RPi server uses lighttpd, several others are available. Looks like lighttpd uses a bit over 1GB of disk, while apache2 uses over 4GB. Others, such as tomcat, will use even more space. Servers which can be installed via “apt-get” (see also “apt search”) basically are just Ubuntu issues and not any different on Jetson/L4T (other than having limited disk space on Jetson).

this is a dumb question (still noob to linux) but can’t i have an external harddrive store apach2 or lighttpd? or better yet can the jetson boot from an external drive?

"better yet can the jetson boot from an external drive? "
Yes

See
https://devtalk.nvidia.com/default/topic/747933/?comment=4535690

Then aslinuxdev says - just install a web server such as lighttpd or apache2 on the external drive

Ahh thank you I will look into that. However, I am still completely stumped on how I should approach this problem. I have installed apache2 no problem and the default page popped up after install. However, I’m unsure of how to get my opencv code in c++ to be the backend for my locally hosted website.

"Here’s the overview of what I would like to do.

  1. Access jetson on lan using a web browser.
  2. User gives image through web browser to jetson server
  3. Jetson server spits back output image to user. "

"However, I’m unsure of how to get my opencv code in c++ to be the backend for my locally hosted website. "

I am afraid that is well beyond my knowledge or expertise. However, I believe you want something like this

https://en.wikipedia.org/wiki/Web_application_framework

Basically, you want a WEB page on the web server that takes the user uploaded image and passes it to your application. This must be done by the dynamic bit of a web page, maybe with Java or PHP or some other language that can be embedded into a web page. The web page code makes a call to start your C++ application.

“(still noob to linux)”
None of this is specific to Linux.

Your application then needs to output the results and make a call to code which updates a web page.

FYI - be careful, you want the code to run on the server - not on a users machine in a web browser.

A quick google, it is possible to develop a C++ application for a web page but most people do not - far to much work. Easier to do it in C# or do it the way I suggested.

This exercise is more challenging than it would first appear, and requires some understanding of how web servers and browsers work together. It’s beyond the scope of this forum (it’s probably more of a Stack Overflow question or go through a couple of tutorials type of thing). I’ll give my 2 cents worth. There are a myriad of ways of solving this, but most approaches require an understanding of the steps involved.

  1. Access to Jetson on LAN through web browser. Install a web server on Jetson and you’re done.

  2. User gives image through web browser to jetson server Most web servers/services have a way to do this, whether it’s passing a URL or uploading an image to the server. Most modern web servers & browsers have well documented ways to do this, depending on the data format.

  3. Jetson server spits back output image to user.
    This is actually two parts -
    3A) Analyze specified image and create modified image
    3B) Serve modified image

3B is trivial using the web server. 3A is the tricky bit.

As you noted, you would like to have the web server “back end” analyze the picture using OpenCV and then save the modified version to a place where the web server can send it back out to the user.

Not surprisingly, this will totally be dependent on the web server that you are using. In the case that you mention, if you are not constrained by the actual web server you choose, try to find one that has an available module or equivalent for interfacing with OpenCV.

For something like Apache, you would most likely write a module (or hopefully find one) to interface with OpenCV. For example, you could use mod_python for interfacing Apache with OpenCV via Python.

If you are comfortable with JavaScript, look at Node.js which is pretty straightforward to interface with C/C++ code. Node.js has an ARMv7 version compatible with the Jetson available on the download page: https://nodejs.org/en/download/ Make sure to select the ARMv7 version. You can then use something like node-opencv (https://www.npmjs.com/package/opencv) for binding to OpenCV. Node.js is popular, and there is a lot of information available.

Your choice will probably have a lot to do with development language(s) which you are most comfortable.

I would expect that there will be (several) issues in getting everything up and running to your satisfaction, but certainly support in the web programming world is more than adequate to get you to your goal. My guess is that the biggest hurdle will be to get OpenCV to link correctly with the web server interface, depending on which version of OpenCV you use (regular OpenCV or OpenCV4Tegra). If you are using SIFT or SURF in your OpenCV processing, you will have to use regular OpenCV.

Hope this helps.

Web programming is a very large topic, and not specific to the embedded world, L4T, or any particular programming language…so many choices and answers to this it would cover several volumes of books. Here’s an answer which is somewhat generic and not an exact answer.

If you want to use CUDA or OpenCV, then your Jetson must have the libraries installed for executing those programs using CUDA or OpenCV. Then any program you put on your system which uses those (e.g., compiled via nvcc) will work with GPU. Many many ways exist to call outside programs in a web server, e.g., simple CGI. You simply need to research how to build that outside program for something like CUDA, then point your web server at this through CGI or similar. Get your program which is called via the web server to work without CUDA/OpenCV, and then adapt the program with CUDA/OpenCV once it works.

As an alternative, if a program calls a library, and if functions in that library can be rewritten and compiled to use CUDA, then the program does not need to know about CUDA and will simply work. So there are your choices…build a program which a web server will call directly designed for CUDA, or build a library which your program (called by a web server) links to, and this will also work.