Recommended Approach for Displaying Third Party Images

I have read a few approaches here for displaying third party images in perspective. I would like to know if there is any approach that is favored?

Setup: I’m running Ignition Gateway Edge on Windows 10 as the HMI for a workcell. I am developing in perspective. I have a Cognex camera which is triggered through tags (OPC for new camera, Modbus for old camera) and drops images into a folder on the Gateway Machine.

Approaches:

  • I can have the Ignition browser access the designated FTP folder but there are permissions and security issues with the browser accessing a local folder
  • I can have the FTP server place images into the Ignition webserver’s folder …/webserver/main but again there are potential permissions and security issues
  • could place images in a local Windows 10 website folder and access them from the Ignition webserver

I’m new to administering FTP and WEB sites on Windows 10 so I may be creating some of my own problems.

Are there other better approaches?
Does the new non-browser based Perspective module solve this elegantly?

Would appreciate any feedback or discussion.

Thank you

Another approach to consider would be to store the images as blobs in the database.

It would get around some of the permissions problems/concerns. Better? All methods have their pros and cons.

EDIT: My manners are atrocious. Welcome to the forums! :slight_smile:

Great suggestion. I think at some point I will have to cross that bridge since inspection images may need to get stored in the database for future reporting.

My reluctance to do that right now is that the images are being generated by the Cognex software/firmware running on the camera and it can’t directly drop it into the database. That still leaves me with accessing the images from within Ignition…

Maybe I need to be looking into file and database manipulate first to get the images where I need them.

I’m new to Ignition and have sold my employer on using it for a couple work cells, so when it comes to learning Ignition, I’m kinda drinking from the fire hose!

Yet another option is to use the WebDev module with it’s Mounted Folder option - anything in a folder will be automatically served up by Ignition (dynamically, when requested).

I’m not sure WebDev is available to me on a stand alone Ignition Edge installation.

1 Like

I have actually completed something similar to what you are trying to do using some custom .NET Core applications. You could look at creating an application that finds new images in a given folder and then uploads/copies into a database. If you have Microsoft SQL Server, FileTables is one such solution to keep images as files without converting to bytes. You could then have an ASP.NET application return the file of the image requested when it receives an HTTP GET request. This allows the use of the Perspective Image component - all you have to do is provide the source link for the image.

There are a few approaches along those lines that I’m exploring. One simple one that I played with for a few hours was to simply move files into a local webserver directory and then access them through an HTTP GET. This can work but I’m still seeking something that can just be easily set up on the work cell laptop and not depend on a lot of other infrastructure.

If keeping everything local to the laptop is the most important aspect, I think your local web server on the laptop could still be the best current solution then (if it is able to present images in the Perspective Image component). Out of curiosity, what is the current problem that you see with the local web server solution that you developed (e.g. ease of deployment, file management, etc.)?

I’m trying to develop a general solution for us to deploy laptops to use as local work cell HMI/SCADA. Most of the work cells employ some kind of visual data collection/analysis using Cognex cameras which I would like to display seamlessly with Ignition. The problems I’m running into are most likely due to my inexperience with Windows 10 networking, permissions and the company’s third party firewall software. With Perspective running in a browser, I need to have a shared location where the Cognex camera can use FTP to store images and Perspective, running in the Ignition browser, can have access to those images. I have not explored the new Kiosk mode, where I believe Perspective is running as a native app rather than in a browser, that could be another option.

I don’t think the Perspective Workstation system allows for local file system access still, unfortunately (I could be wrong, or this could be a feature coming). However, the Vision image component does allow for accessing client file paths. https://docs.inductiveautomation.com/display/DOC81/Vision±+Image

If you are set on using Perspective though, I still would suggest that you look at an ASP.NET application - you can create one yourself in Visual Studio Code that returns an image relatively easily (and publish as a self-contained application that you can just start and run on your workstations). Below is a snippet of a controller from one that I just put together to return a file with filename “image1.jpg”. - the request was just https://localhost:5001/Image/1

        public async Task<IActionResult> Download(long id)
        {
            var filePathPrefix = "C:\\image" + id + ".jpg";

            Image imageHolder = Image.FromFile(filePathPrefix);


            var memory = new MemoryStream();

            imageHolder.Save(memory, System.Drawing.Imaging.ImageFormat.Jpeg);
            memory.Position = 0;


            return File(memory, "image/jpeg", "file" + id + ".jpg");
        }

The neat part is that is about all the code there is to it - I modified Microsoft’s web API tutorial to make the above code the action of the GET request in their template (and added System.IO and System.Drawing.Imaging namespaces). Check out Microsoft’s template for more info on getting started:
https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.1&tabs=visual-studio-code

However, if you already have some kind of a local file server that can return files via HTTP requests, then none of this is needed :smiley: (unless you want to have some degree of customization).

1 Like

If these machines will have Python 3 installed you can start a simple HTTP server like this:

python -m http.server -b localhost -d /path/to/images
3 Likes

That’s quite a bit simpler of a solution than mine :laughing:. Didn’t realize there are HTTP server capabilities for Python!

Nathaniel,

Thank you for all the help! Some great ideas and I’ve filed them away for when they might be appropriate.

I tried Kevin’s python webserver approach (I didn’t realize this was baked into Python 3 either!) and it worked just fine here in my home shop where I’m playing with everything via the Maker edition. It’s an elegant solution for me because I can let Cognex put the images in their program directory or wherever default and just point to it with the Python server.

Thanks again for all of the responses. I’m liking this community and that’s a good thing since I’m diving headlong into Ignition.

2 Likes

Kevin,

I’ve given this a try in my home shop and it works great! Thank you.
I can tell you this, if the work cell PC’s at the job don’t have Python 3 installed… they will have it installed tomorrow morning! haha

Regards,
Tanda

1 Like

For anyone following along, here is a brief summary of how I implemented this solution:

I use Tags in Ignition to poke a module number and inspection point (terms unique to my application) into the Cognex Spreadsheet via OPC or Modbus (for those unfamiliar with Cognex, a spreadsheet is how Cognex cameras store/present the code for an inspection job). I use these values in the Cognex code to build a unique filename and then when I trigger the camera, also through a tag in Ignition, I’ve coded the camera to then send the image to a folder via FTP.

Using Kevin’s suggestion of creating a simple http.server using python
See above: Recommended Approach for Displaying Third Party Images
I point the simple python webserver at the directory where the images are being stored and bind it to a local IP address on the work cell PC that is running Ignition Gateway. The work cell PC has a separate ethernet port for talking with cameras, robots etc. in the cell and that is all behind a router in the work cell so the simple python server is pretty secure.
Boom! now I can use a memory tag to build the “http://localhost:8000/MODxxINSPxx” value for an image component and display inspection images as they are being captured.
My Ignition App is now driving all of the file naming, camera triggering, and robot positioning, based on a recipe file I’ve had the operator load in using a “file upload” component.

Thanks everyone for all the help!
-Tanda

9 Likes

hello Tanda,
I’ve been struggling to find out how can i integrate python with Cognexx, i would be so grateful if you could help me
i tried to connect with Cognex via telnet but the camera doesn’t receive commands

Some of the newer cameras have an OPC server built in. However, I haven’t done much with that yet.
I’ve found the easiest way to connect a camera with Ignition is through Modbus. If you are using Insight Explorer to develop your project, and your camera firmware is newer than 5.3.0, there is a setup for Modbus communications. Here is a link to a cognex page on the register architecture:
https://support.cognex.com/docs/is_574/web/EN/ise/Content/Communications_Reference/ModbusTCP_5x.htm
If you need to capture images from the camera, maybe after triggering it from the Modbus link, there is a function to do an FTP write that will store the image off onto an ftp server.
Hope this helps a bit. I’m fairly new to this myself so certainly not an expert. I’m just relating what I’ve discovered.

I replied a few days ago and just noticed that it was a separate post rather than a reply directly to you. I’m replying here so you get an alert.

Oh right ,
I need to do the image processing Of the images captured from the camera cognex using python and openCv, so should i use ftp Server or modbus tcp to communicate ?
Thank you very much

I think I would use the built in ftp transfer from the Cognex to an ftp server. Then you have the files where you can run your analysis on them.