DULMEN.net   Follow me on Facebook Contact DULMEN.net  

WMImage - Programming@DULMEN.net

WMImage
Hidden program that pops up a window when it detects an image in a configured folder. The user can choose if he/she wants to keep or throw the image. It is written to work in collaboration with software for controlling a KHT Multiscan measuring machine but can also work with ProductImage.
 
Features
-Start WinPBM or Masterdata Connect from start screen
-Optionally starts WinPBM or Masterdata Connect automatically
-Application minimizes to system tray when inactive
-Positioning of pre-defined window e.g. camera settings window
-Pops up a window with the just created product image (not in silent mode !)
-User can choose to accept or decline the image
-Converts BMP images to JPG format
-Resize images to predifined size
-Processes measurement data generated by source program
-Optionally saves measurement data to CSV and/or text file(s)
-Adds measurement data to accepted images (product identification, source, date)
-Optional silent mode (no user intervention)
-Optionally send accepted images to a FTP server
-Optionally change file names to uppercase
-Optionally strips date/time stamps from the end of file names when uploading with FTP
-Optionally pops up a window if image allready exists on FTP server
-Optionally saves a backup if image is overwritten on FTP server
-Optionally prints a label to network connected and FTP enabled or shared Zebra printer
-Reprint labels from system tray menu
-Optionally cleans local files older than preset number of days once a day
-Able to upload all measurement data once a day
-Start cleanup from system tray menu
-Optimized and tested to work in conjunction with KHT WinPBM V1.52 revision R05 or Logistore Masterdate Connect v1.0
-Tested to work with ProductImage (although many features are disabled for this)
-Conversion of weight and sizes units if needed
-Proces product identification's containing a \ or /
 
Description
This project has become fairly complex over time. It started with the need to give users an option to choose wether they wanted to keep or throw an image created on the KHT Multiscan machines. These machines measure a product and can make a picture of it using a webcam. These measurements and image are added to the masterdata of the products in the warehouse database (WM).

The machines are controlled by software. Depending on the age of the machine this software is:

- KHT WinPBM P950 v1.52
- Logistore Masterdata Connect v1.0

Both programs have the same function and if configured correctly output the same data. The measurements are saved in a data file with a CSV kind of structure:

Barcode;SKU;Notation;PackageUnit;Quantity/PU;Mean Value;Length;Width;Height;Volume;Volume Unit;Weight;Date;Time

The images are saved with the product indentificatie code as filename. Whenever a new picture is created WMImage grabs it and tries to find the corresponding data from the data file. It then asks the user if he/she wants to keep the picture. If so, it writes the measurements inside the image and saves it in a folder or sends it to an FTP server.

Optionally WMImage can create a small file containing the measurements of the product (in INI and/or CSV format) and can send it to a separate folder on the FTP server. Later on I noticed the users wrote down the measurements on a piece of paper to enter it in the warehouse manager's user interface on a touchscreen computer. This was a cause of many errors.
A solution for this, without the need to change the warehouse software itself, was to print a label with the measurements as barcode. This functionallity was added to WMImage using a Zebra QLn420 label printer.
The user can now rip off the label and scan the barcode on the touchscreen computer running the warehouse manager user interface.

For the labels WMImage uses a template saved in the Zebra ZPL code (see downloads). The fields for the measurements are keywords surrounded by parentheses. These keywords are replaced with the actual measurements and the file is saved with the product identification as file name and send to the Zebra label printer. From the tray menu the last label can be reprinted or users can pick one from the previously saved labels.

WMImage can also handle images in silent mode. In this mode all images are automatically accepted and send to the FTP server. To inform users about what is happening in the background or if there are errors I added the option to show a popup message on the screen whenever an image is processed and when an error occurs. These messages desappear automatically.
Because the messages are only shown briefly (default is 5 seconds) the last error message can be recalled from the tray menu.

To prevent that the local harddisk gets overloaded with images and measurements WMImage can perform a daily housekeeping task. It can clear all data older than X days. See the configuration file settings for details. Housekeeping can also be started manualy from the tray menu.

The FTP part of WMImage gave me some headaches. I noticed occasional crashes of WMImage from version 1.2 and I almost rewrote the whole code just to find the cause. This is why WMImage has so many versions 1.5 (a..f) and an extensive logging mechanism which can log almost every step in the program (if set to debug).

Version 1.6 (although not tested in practice yet) can proces images with encoded / or \ in the filename See screenshot below as an example: the real code is CNY544000D/1 but it is handled as CNY544000D{2F}1). As from this version WMImage can also send a daily (or any number of days) list of measurements to the server.

Due to network changes I added support for copying the images and measurements to a shared SMB resource in version 1.7 as in the new network setup no FTP server is available. I also made the screen independed of the Windows monitor scale setting and added icons to the tray menu.
 
Screenshots
WMImage processing an image created with Masterdata Connect, note the "WMImage-New image found" window, the "WMImage popup message" and the "Logitech WebcamController"
 
WMImage system tray menu WMImage barcode label with measurements
 
Commandline options
No command-line options available.
 
Configuration file settings
[ApplicationOptions]
SourceApplication Imaging and measuring path\application
SourceApplicationName Imaging and measuring application name (for button label)
AutoStartSourceApp Auto start imaging and measuring application (1 = yes, 0 = no)
StartMaximized Start measuring application full screen (1 = yes, 0 = no)
KeepMaximized Keep measuring application full screen (1 = yes, 0 = no)
WriteLog Write messages to logfile (1 = yes, 0 = no)
MaxLogSize Maximum size for log file in Kb
SilentMode Image handling withoud user intervention (1 = yes, 0 = no)
AcceptLeftPos Left position for accept image question in pixels (negative values are calculated from the right)
AcceptTopPos Top position for accept image question in pixels (negative values are calculated from the bottom)
WarningMessageSec Time in seconds a warning message is displayed in the lower right corner (0 = off, default = 5)
DebugMode Add more messages to the log file for error analysis (default = 0)
UnitID ID of the measuring unit stored in the image and measurement file(s)
[KeySubstitudeOptions]
KeySubstitution Substitude keyboard keys / and \ by configurable codes (1 = yes, 0 = no)
SlashSubstitude Code to replace / (default = #2F)
BackslashSubstitude Code to replace \ (default = #5C)
[WebcamOptions]
WebcamProgram Webcam control application title
WebcamLeftPos Left position for webcam control panel in pixels (negative values are calculated from the right)
WebcamTopPos Top position for webcam control panel in pixels (negative values are calculated from the bottom)
[MeasurementOptions]
DataFolder Folder where the source program stores the measuring data
CreateCsvFile Create a CSV file with product measurements (1 = yes, 0 = no)
CreateCsvList Add measurements to a data list in CSV format (1 = yes, 0 = no)
AddCsvHeader Include header in CSV list or files (1 = yes, 0 = no)
CreateTextFile Create a text file with product measurements (1 = yes, 0 = no)
StoreInImage Store measurements inside images
IncludeFields Include/exclude data fields (11111111111111 = all, 00000000000000 = none)
DestinationFolder Destination folder for storing text and CSV files
WeightUnitInput Weight unit used by source (g, kg, default = g)
WeightUnitOutput Weight unit for output (g, kg, default = kg)
WeightDecimals Number of decimals for weight value (0 to 3, default = 3)
SizeUnitInput Size unit used by source (mm, cm, m, default = mm)
SizeUnitOutput Size unit for output (mm, cm, m, default = mm)
SizeDecimals Number of decimals for size values (0 to 3, default = 0)
[ImageOptions]
ImageFolder Folder where the source program stores the product images
ImageDeclinedFolder Folder for storing declined images
ImageAcceptedfolder Folder for storing accepted images
JPGCompressionQuality JPG compression quality (1-100, higher value results in higher quality)
DateLength Number of characters used for date/time stamp at the end of image file names (0 = no date/time stamp)
Capitalize Change image file name to uppercase (1 = yes, 0 = no)
ImageWidth Image width in pixels
ImageHeight Image height in pixels
[UploadOptions]
UploadToServer Upload to server (0 = no, 1 = SMB, 2 = FTP)
UploadImages Send images to WM's FTP server (1 = yes, 0 = no)
UploadMeasurements Send measurements to WM's FTP server (1 = yes, 0 = no)
AskOverwrite Ask before overwriting image on WM server (1 = yes, 0 = no)
OverwriteLeftPos Left position for overwrite question in pixels (negative values are calculated from the right)
OverwriteTopPos Top position for overwrite question in pixels (negative values are calculated from the bottom)
ImageFolder Remote folder for saving images (empty for FTP root)
MeasurementFolder Remote folder for saving measurements (empty for FTP root)
BackupFolder Remote folder for image backups (cannot be same as ImageFolder !)
LocalTempFolder Local folder for temporary storage of duplicate images
LocalErrorFolder Local folder for storing images in case of upload errors
[FTPOptions]
ServerIP IP address of the FTP server
Username Username for the FTP server
UserPassword Password for the FTP server
[HousekeepingOptions]
CleanupAcceptedImages Cleanup accepted images older than X days (0 = disabled, X = number of days)
CleanupDeclinedImages Cleanup declined images older than X days (0 = disabled, X = number of days)
CleanupTempImages Cleanup temporarily images older than X days (0 = disabled, X = number of days)
CleanupErrorImages Cleanup error images older than X days (0 = disabled, X = number of days)
CleanupMeasurements Cleanup measurements older than X days (0 = disabled, X = number of days)
UploadCsvList Upload CSV data list (1 = yes, 0 = no), if enabled make sure CreateCsvList is 1 and UploadToServer settings are set
RemoveDataFile Remove source datafile(s) (1 = yes, 0 = no)
HousekeepingHourNum Autostart housekeeping at specified hour (Allowed values 00 to 23, 0 = disabled)
[LabelOptions]
PrinterType Print label with dimensions and barcode (0 = none, 1 = local shared, 2 = FTP)
ShareName Shared printer name (e.g. \\localhost\Zebra)
LabelFolder Folder for storing label files
PrinterIP IP address of the Zebra printer
PrinterUser Username for the Zebra printer
PrinterPassword Password for the Zebra printer
CompanyName Company name for label
 
Version history
v1.0 Initial setup
v1.1 Bugfixes 01, 02
Added suport for metadata in accepted images
Added additional error handling and logging
v1.2 Buxfix 03
Added support for remote directory
Added silent mode
Added processing of measurement data
v1.3 Buxfix 04&05: added Try-Catch on folder scanning
Bugfix 06: removed 1000's separation
Added FTP folder option for measurement data (different folder then images)
Backup duplicate images on FTP server
Ask Overwrite option also available in Silent Mode
Added local folder in case of FTP errors
Store measurement data inside images
Added housekeeping to cleanup local folders
v1.4 Added label print functions
Bugfix 07: trim file name and discard files with empty product identification number
Bugfix 08: added writelog
Improved error handling
v1.5a Compiled with updated AHK (v1.1.28.00)
Temporary debug messages during image FTP upload to analyse bug 09
v1.5b Some changes to support Logistore Masterdata Connect
Added full screen options for source application
Added log file view to system tray menu
Added support for local or remote shared Zebra printer
Bugfix 10: set disabled menu items correctly at startup
Added size and weight unit conversion option
Added size and weight value decimals option
Added Debug option
v1.5c Rewrite of image detecting loop (bugfix 09)
Rewrite of measurements extracting loop
Parse all data files to find most recent product identification match
Removed FTP progress windows (was flashing annoyingly)
Removed DateInName option (see DateLength option)
Added a brief warning message if errors occur during image handling disregarding the SilentMode setting (0 = off)
Disabled label printing if more than 5 images are being processed
Fixed date/time stamps in FTP module
Several small enhancements and fixes
v1.5e Bugfix 09 Removed error status lookup in FTP functions (GetModuleErrorText)
v1.5f Added debug messages for brief warning messages
Added configurable window positions
Bugfix 11 Disabled the repeating SetTimer commands when warning message windows are closed
v1.6 Added option to create a measurement list and upload it during housekeeping actions
Added support for product identification's containing a / or \ by substituting keyboard input / with [2F] and \ with [5C]
v1.7 Added support for upload images and measurements to SMB share
Changed trailing date/time format for declined or backed up images
GUI sizes independed of Windows DPI setting (monitor scale setting)
Removed date/time in message window
Jump to the end when opening log file
Moved icons and logo's to WMImage.dll
Bugfix 12 Added the StoreInImage condition for measurement processing
Bugfix 13 Improved key substitution
 
Known bugs
Bug no. Version Fixed in Description
01 v1.0 v1.1 When a bmp image bigger than 640x480 is displayed it is not cropped to the window size
02 v1.0 v1.1 If there are capitals in the file extension the image will not be processed
03 v1.1 v1.2 Duplicate message in logfile when starting WinPBM with button and auto start is turned on
04 v1.2 v1.3 Program stops working, tray icon still visible but disapears on mouse-over
05 v1.2 v1.3 Program crash after accessing local image folder with Windows explorer (simultaneously with image folder scan ?)
06 v1.2 v1.3 Volume measurement in US notation (comma separated 1000's)
07 v1.3 v1.4 If WinPBM uses leading spaces in image file name this causes errors on the FTP server
08 v1.3 v1.4 No messages in log file after exceptions
09 v1.4 v1.5e Unexpected program crashes (when checking if image already exists on server)
10 v1.4 v1.5b Print option in tray menu also active with disabled print option
11 v1.5e v1.5f Brief messages not popping up after some operation time
12 v1.6 v1.7 No measurement data inside image if no measurement files are created
13 v1.6 v1.7 Keys ? (shift-/) and | (shift-\) result in / and \
 
Future enhancements
Add configuration screen.
 
Download
Please read the legal notice first, allthough you probably heard it before :)


Copyright 2018 DULMEN.net. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY DULMEN.net ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL DULMEN.net OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of DULMEN.net.


You can download WMImage as a compressed folder containing all files needed. No need to install the software, just unzip, adapt the configuration file WMImage.ini and run WMImage.exe.
WMImage is free for personal and bussiness use and is free to distribute as is as long as the program is not altered and accompanied with the WMImage text file.

VersionFileSize
v1.7WMImage_v1.7.zip2,04 MB (2139856 bytes)
v1.7WMImage_v1.7.7z1,56 MB (1631142 bytes)
v1.6WMImage_v1.6.zip1,23 MB (1291319 bytes)
v1.6WMImage_v1.6.7z1,01 MB (1055068 bytes)
v1.5fWMImage_v1.5f.zip1,23 MB (1291872 bytes)
v1.5fWMImage_v1.5f.7z1,01 MB (1054329 bytes)
WMImage_ZPL_Manual.pdf14,36 MB (15060650 bytes)
WMImage_KHT_MultiScan_NL.pdf229,25 KB (234752 bytes)
 
 
Share
DULMEN.net © v8 2018 - Designed & written by Arno van Dulmen