cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

How to read and captures an image directly from a camera to be processed in mathcad

gcevallos
6-Contributor

How to read and captures an image directly from a camera to be processed in mathcad

‌How you are read and captures an image directly from a camera to be processed in mathcad. The idea is read images within a sequence of programming and process each image captured with a target particular.

9 REPLIES 9

May be this help you (Mathcad 15):

LucMeekes
23-Emerald III
(To:gcevallos)

You would have to store the image on disk, in a file format supported by Mathcad (.BMP, .GIF, .PCX or .TGA).

The 'on disk' could also be inside your camera, provided the camera is connected to the PC that runs Mathcad, and gives file access to this disk from within the PC (like a memory stick).

Then you can read the file with the function READRGB. Then you can process the image data.

It's more challenging, though I think not impossible, to write a Mathcad program that checks for new images and processes them as they become available. At least it would require some sort of sequence number in the image file name.

Success!
Luc

gcevallos
6-Contributor
(To:LucMeekes)

‌I will try this way, but the idea is to have a process in real time, synchronization of  reading, writing from the camera to record and further reading from the mathcad will be the challenge

LucMeekes
23-Emerald III
(To:gcevallos)

OK, Here you go:

The above function RepeatProcessPictures() will scan and compare the srcpath directory contents and dstpath directory for file(s) that are in the srcpath directory but not in the dstpath directory. If it encounters such file(s) it will process them.

In this case, 'processing' is just copying from srcpath to dstpath.

After every scan it waits 10 seconds before a next scan is started. If no new files are found on the srcpath withy respect to the dstpath, the function will stop.

You can check this function by having two directories, one with a number of picture files (note that in this implementation only .jpg files are processed.) and the other one directory is empty.

Run the function once and wait 10 seconds.

The function returns with the list of files it has processed. Here's an example:

Run the function a second time and wait 10 seconds. No new files are added to srcpath, this is what it returns:

Run the function a third time, and while it runs rename a few of the picture files in the srcpath directory. This is my fastest way to simulate that new pictures are added to srcpath. Again, wait 10 seconds for the result. Here's an example:

I should think this does what you want, albeit in a somewhat crude manner.

Note that I'm using a compute intensive method to build a delay with my Wait() function. You may not need this if your processing takes enough CPU time by itself...

Success!
Luc

gcevallos
6-Contributor
(To:LucMeekes)

‌I tried using to "Path" the directory of the camera of the photos built-in to the computer. In addition the function "Files" in its definition of Jpgfiles not was recognized for Mathcad. also required some additional explanation of the variables "srcpath" and "dstpath"

LucMeekes
23-Emerald III
(To:gcevallos)

Ah, Sorry. I used the function Path() that works in Mathcad 11 (although undocumented) and apparently it does not work in your (newer?) version of Mathcad.

At the moment I have no solution around that. Maybe someone else can help.

When you call the function RepeatProcessPictures() you must supply it two parameters:

srcpath     = the path where your source picture files are stored.

dstpath     = the path where you want your processed pictures to be stored.

Luc

I assume you mean the function Files(), not Path().

Here's a potential solution:Read filename list in a known folder from within Mathcad

I didn't have much luck, but didn't spend a bunch of time on it.

LucMeekes
23-Emerald III
(To:MJG)

You're right Mark. I meant Files() not Path().

Luc

MJG
18-Opal
18-Opal
(To:MJG)

I couldn't resist playing a little more.

I think the attached file should work.  Note that you'll need to say "no" to Mathcad's request to disable components.

In playing, I found that you have to have at least 2 JPG files in srcpath and dstpath (each) for Luc's programming to work.

Top Tags