Skip to main content
6-Contributor
September 19, 2016
Question

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

  • September 19, 2016
  • 9 replies
  • 3179 views

‌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

24-Ruby IV
September 19, 2016

May be this help you (Mathcad 15):

23-Emerald IV
September 19, 2016

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

gcevallos6-ContributorAuthor
6-Contributor
September 21, 2016

‌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

23-Emerald IV
September 22, 2016

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