Computer Vision-Based Portable System for Nitroaromatics Discrimination

A computer vision-based portable measurement system is presented in this report. The system is based on a compact reader unit composed of a microcamera and a Raspberry Pi board as control unit.This reader can acquire and process images of a sensor array formed by four nonselective sensing chemistries. Processing these array images it is possible to identify and quantify eight different nitroaromatic compounds (both explosives and related compounds) by using chromatic coordinates of a color space.The system is also capable of sending the obtained information after the processing by aWiFi link to a smartphone in order to present the analysis result to the final user.The identification andquantification algorithmprogrammed in theRaspberry board is easy andquick enough to allow real time analysis. Nitroaromatic compounds analyzed in the range of mg/L were picric acid, 2,4-dinitrotoluene (2,4DNT), 1,3-dinitrobenzene (1,3-DNB), 3,5-dinitrobenzonitrile (3,5-DNBN), 2-chloro-3,5-dinitrobenzotrifluoride (2-C-3,5-DNBF), 1,3,5-trinitrobenzene (TNB), 2,4,6-trinitrotoluene (TNT), and tetryl (TT).

Therefore, the reliable detection of explosives and related compounds is a sensing challenge for different fields such as military operations, public security, criminal investigation, and pollution control [8][9][10].In these fields, different circumstances must be faced such as low levels of explosives in most practical scenarios, multiple interferences from common household and personal care products, variable environmental conditions, and the need for low-cost, on-site, real time, and highly portable detection methods.
Various high resolution analytical techniques and strategies, including ion mobility spectrometry [11,12], chromatography [13,14], mass spectrometry [15,16], nuclear quadrupole resonance [17], energy dispersive X-ray diffraction [18], and Surface Enhanced Raman Spectroscopy [19,20], have been reported for the sensitive and selective detection of these explosives.Nevertheless, these methods suffer from drawbacks such as cumbersome pretreatment of samples, 2 Journal of Sensors interference from other compounds, trained staff, or bulky instrumentation [14].An alternative approach overcoming some of these drawbacks relies on the biomolecular recognition capability of the biological element (e.g., antibody) for a target molecule (e.g., antigen) as fiber optic probes [21].However, analyzing complex mixtures of compounds with this high selective approach requires the design and synthesis of receptors for each component in the mixture, which is often an extremely time-consuming and expensive task.
On the other hand, resembling mammalian senses such as olfaction and taste, instead of identifying an analyte by its strong affinity for one particular receptor, recognition can be achieved by the composite response of the entire array of semiselective receptors.The result is a characteristic pattern, or fingerprint, for each analyte.An important advantage of this approach for molecule identification is that the system is limited by the number of different patterns possible for an array of receptors rather than the number of different receptors.Thus, the different receptors need not be highly specific for any particular analyte.Moreover, this array approach allows the discrimination of analytes or analyte mixtures that have not been exhaustively characterized.Colorimetric sensor arrays have been extensively developed for this purpose because of the potential for high sensitivity, good selectivity, rapidity of analysis, portability of instrumentation, and overall cost-effectiveness [2].
However, sensor array approaches produce a large amount of data which is usually not interpretable by visual inspection of the dataset or by using basic calibration procedures like a simple linear regression.Therefore, chemometric methods are usually applied to reduce the dimensionality of the data for simplifying visual interpretation.Among them, principal component analysis (PCA), hierarchical cluster analysis (HCA), linear discriminant analysis, and artificial neural networks (ANN) are the most common techniques [22].They can be somewhat time-consuming computational methods which could prevent a true real time measurement.
Image processing is a common technique for measuring colorimetric response of optical sensors [1], including sensors for explosive determination [2,6,23].In this work, this strategy has been adopted.Low-cost, on-site, and real time measurements are some of the objectives of the developed prototype in line with current portable analytical instrumentation [1].Thus, we have developed a fully portable and wireless measurement system for the identification and determination of explosives and related compounds when they are mixed in a solution.It is based on a colorimetric sensor array, an electronic reader unit with a microcamera for the acquisition of an image of the sensor array, and a software application running in a smartphone capable of showing the results in an easy and direct way.A set of eight nitroaromatic compounds have been analyzed with a sensor array using four different sensing chemistries.This has been possible by programming a simple algorithm which allows the simultaneous identification and quantification of these compounds in a mixture of dissolved analytes.The main novelty of our design compared to others [2,[4][5][6]23] relies on being a low-cost, compact, and wireless system which allows getting real time and in situ information about a large number of nitroaromatic compounds even mixed in a solution.

Instruments and Software.
The electrical characterization of the system was carried out using the following laboratory instrumentation: a mixed signal oscilloscope MSO4101 (Tektronix, Oregon, USA), 81/2-bit Digital Multimeter 3158A (Agilent Technologies, California, USA), 15 MHz waveform generator 33120A (Agilent Technologies), a DC power supply E3630A (Agilent Technologies), and balance DV215CD (Ohaus Co., New Jersey, USA).For testing and calibration purposes, the software Matlab (MathWorks, Inc., Massachusetts, USA) and Adobe Photoshop (Adobe Systems Inc., California, USA) were used as well.

Sensing Array Preparation.
The disposable sensor array was prepared by laser-cutting technique, because it is a costefficient, simple, and reproducible process, using standard laboratory filter paper (Filter-Lab, ref. 1250).The pattern was designed using Illustrator software (Adobe Systems) and then exported as an FS file to the controller software of a desktop laser engraver Rayjet with a CO 2 laser source (Trotec Laser GmbH, Wels, Austria).For the fabrication, a piece of paper was affixed using double-sided adhesive tape to a white plastic sheet.The removal of weeding was performed manually.The design consists of 4 circles of 5 mm diameter arranged on 2 columns and 2 rows with dimensions indicated in Figure 2. The size of the array and spots and their distribution were designed taking into account the field of view of the microcamera and the number of spots in each picture.The device was prepared by drop-casting in each sensing area the needed reagents under ambient atmospheric conditions.

Description of the Measurement System.
The developed measurement electronic system is aimed at registering and quantifying the color variation of the sensing membranes when a volume of a solution containing some of the nitroaromatic targets described above is added over them.The prototype is composed of a reader and processing hardware unit which sends the information to a mobile device (such as a smartphone or tablet) with a customized Android application to show the result of the analysis carried out to the final user.The information gathering is based on the color variations of a colorimetric chemical sensor array when exposed to the analytes.The capture and processing of the sensor array image are, respectively, carried out by a microcamera and a microprocessor included in the reader unit and results are sent to the mobile device of a remote user via a WiFi link.Although other systems have been already reported following this approach [24], our system presents the characteristic of being fully portable and remotely operable.
Sensing Module.As it has been already explained, the instrument is based on the acquisition and processing of the image of the sensor array in order to quantify the color variations and to relate them to the presence of some nitroaromatic compound.Figure 1 shows a diagram of the prototype.The processing electronics is enclosed in a dark box of dimensions 13 × 13 × 5 cm 3 with a slot for the insertion of the sensor array.
As it can be seen, the core of the instrument is a commercial Raspberry Pi platform, the Raspberry Pi 2 model B (Raspberry Pi Foundation, United Kingdom).This is a low-cost device that includes a 900 MHz quad-core ARM Cortex-A7 CPU and 1 GB of RAM.These specifications make this platform a powerful tool for fast image processing.In addition, the Raspberry Pi 2 model B counts with 4port USB for connection of external modules, a camera interface (CSI), and a micro-SD card slot which allows expanding the memory capacity in order to store the taken images.Besides, the Raspberry Pi board provides 40 general purpose input/output (GPIO) ports allowing us to include some external elements such as the light source used for the system.The microcamera used is the model Raspberry Pi camera (Raspberry Pi Foundation, United Kingdom), which is compatible with the Raspberry Pi platform.It is a high resolution camera, up to 5 megapixels, based on the image sensor OmniVision 5647 (OmniVision Technologies, California, USA).This camera allows acquiring both video and still photographs.It is connected to the Raspberry core through the available CSI.
To obtain uniform and stable illumination for the acquisition of the image, two diffuse white light emitting diodes (LEDs), model ASMT-MWH (Avago Technologies, Singapore), are disposed in the inside of the box.The operation of the LEDs is controlled by the Raspberry Pi core through two digital outputs that switch them on and off.The intensity of the emitted light is manually adjusted by means of a potentiometer, so that overexposition and subexposition are avoided during the acquisition procedure.
An external module for setting up a WiFi network has been added to the Raspberry Pi board.This is the model Miniature WiFi (Adafruit Industries, New York, USA) that is fully compatible with the Raspberry Pi platform to which is connected through a USB port.It implements wireless standards: IEEE 802.11n (draft), IEEE 802.11g, and IEEE 802.11b.The whole system is battery-powered.A large-sized rechargeable battery pack is included in the design (Adafruit Industries, New York, USA).Inside is a massive 10.000 mAh lithium ion battery that provides 5 VDC and 2 A via a USB-A port.The total weight of the reading unit is 150 g.Android Application.An application based on Android operative system has been developed in order to allow the remote control of the instrument through smart devices such as smartphones or tablets.In order to implement the application, Eclipse v22.3.0 was chosen as the integrated development environment (IDE) since the plugin needed to integrate Android is more developed than for other IDEs and, also, a phone emulator can be used for debugging purposes.The application establishes a WiFi-based wireless communication with the Raspberry Pi board through which the user requires a measurement and receives the resulting data, presenting them to the user through a simple and intuitive interface.

Measurement Procedure.
The reagents used for the colorimetric determination of the nitroaromatic compounds are creatinine, potassium hydroxide, aniline, and N,Ndiethylaniline.Creatinine is dissolved in NaOH 0.1 M with a creatinine concentration of 100 mmol/L; KOH is dissolved in ethanol and its concentration is 100 g/L; finally, aniline and N,N-diethylaniline are used without dilution.The standards containing the analytes picric acid, 2,4-dinitrotoluene, 1,3dinitrobenzene, 3,5-dinitrobenzonitrile, and 2-chloro-3,5dinitrobenzotrifluoride are prepared by dissolving them in acetonitrile : methanol (1 : 1) mixture.In the case of 1,3,5trinitrobenzene, 2,4,6-trinitrotoluene, and tetryl, a 1000 mg/L standard solution in acetonitrile : methanol (1 : 1) is used.The dilutions used in this study are obtained from these dissolutions.
The measurement procedure consists in the addition of 5 L of sample to each of the paper spots present in the plastic cardboard and later 5 L of one of the reagent solutions in each spot.Each reagent solution must be added in a predetermined position in the card.After the addition, 15 minutes is waited in order to let the reactions occur and to capture a picture of the complete colorimetric signal.Afterwards, the card is introduced in the reader unit and an image is taken from the cardboard.Safety Note.Some of the nitroaromatic compounds analyzed in this study show explosive character.For this reason, the handling of the samples must be carried out with precautions, paying extra attention to the amount of the manipulated compounds, temperature variations, and possible impacts.

Results and Discussion
3.1.Nitroaromatics Recognition.The recognition of eight nitroaromatics under study was performed using a white plastic board containing an array of paper circles fabricated by craft-cutting technique.Three different reactions were used for detection and determination of these compounds.The reaction of aromatic polynitrocompounds with carbanions results in the formation of Janovsky -complexes [25].The red-orange color and the intensity depend on the nitroaromatic substance that is present and its concentration.The reagent used is creatinine in basic medium (Jaffe reaction) [26,27].A second reaction takes place using potassium hydroxide in ethanolic solution that results in colored Meisenheimer type complexes in some cases and colored anions in others [28,29].Another reaction responsible for the formation of colored products with nitroaromatics involves the use of basic reagents such as aromatic amines based on a charge transfer mechanism in which the aromatic amine acts as a  donor whereas the nitroaromatics serve as  acceptor [28].We used this last reaction with two different reagents, aniline and N,N-diethylaniline, increasing in this way the discrimination power of the array.

Image Processing.
The core of the reader unit, that is, the Raspberry Pi board, is programmed to carry out processing of the acquired images in order to obtain quantification of the color of each membrane.This image processing consists of an algorithm that provides only one parameter related directly to the color change registered for each reaction.The first step of this algorithm consists in the selection of the regions of interest (ROIs) in the sensor array.These are the central zone of each membrane, discarding the edges where some nonuniformities of the membrane can be found.In addition, a region in the blank space of the board is also selected as a region of reference (ROR), as it is depicted in Figure 2.This fifth region is used to normalize the color quantification of the previous four regions corresponding to the sensitive membranes, in order to correct color measurement drifts caused by intensity changes in the biasing of the white LEDs or small nonuniformities in the illumination due to misalignment of the membrane board and the white LEDs.
After these ROIs are selected, the algorithm extracts the value of the red, green, and blue (R, G, and B) color coordinates of each region as the most frequent values (the statistical mode) of R, G, and B of the pixels inside each ROI.These values define the three chromaticities that allow unequivocally specifying a color in the RGB color space.From these values, normalized coordinates R  , G  , and B  for the ROIs corresponding to the sensitive membranes are obtained as the ratio between the RGB coordinates of this region and the RGB values of the fifth region corresponding to the blank space between membranes in the board, which is considered as the white reference.Although these normalized values of the RGB coordinates allow quantifying the color of the membranes, these data are reduced to only one to simplify the information on the color variations.With this aim, the Euclidean distance of the color of each membrane before and after the reaction with the explosive sample is considered.This distance is defined as the difference between the initial color coordinate and final color coordinate of the analyzed samples [30]: where   0 is the normalized color coordinate (red, green, or blue) before the reaction with the sample and   is the corresponding normalized coordinate after the reaction.
By means of the colorimetric distance , only one parameter is used to measure directly the color variation that the membrane suffers when it is reacted in the presence of a nitroaromatic compound.

Calibration Curves.
The calibration of the measurement system was performed using separated solutions of the analytes: picric acid, 2,4-dinitrotoluene, 1,3-dinitrobenzene, 3,5-dinitrobenzonitrile, 2-chloro-3,5-dinitrobenzotrifluoride, ranged from 1 to 20 mg/L, and 1,3,5-trinitrobenzene, 2,4,6-trinitrotoluene, and tetryl, ranged from 1 to 100 mg/L, with four replicas per solution and for each one of the four mentioned reagents above.This procedure results in 38 calibration curves with four replicas for each of them.Errors have been calculated as the standard deviation of experimental data.The calibration was carried out as described in the measurement procedure section, obtaining a color change on the paper when the reagents are added.In Figure 3 some examples of color variation of two reagents can be observed when they are reacted with different concentrations of analytes.
The Euclidean color distances have been extracted for all the analytes in concentration ranging from 1 to 100 mg/L.The results show that this parameter presents a tendency that can be fitted to a simple calibration curve (linear, exponential, or logarithmic) for two reagents at least. Figure 4 shows some examples of the fitting curves obtained for some reactions between some of the reactants and nitroaromatic compounds.
In Table 1, the different fitting equations found in the calibration procedure are presented, where  is the concentration of the nitroaromatic compound and  is the calculated Euclidean colorimetric distance.

Analyte Determination Algorithm.
Principal component analysis (PCA) is a standard technique for samples separation and/or classification in a solution with a mixture of analytes [31,32].In this work, we propose developing an even simpler algorithm able to calculate the presence and concentration of certain nitroaromatic compounds, some of them explosives, thus making the use of computationally costly multivariable techniques unnecessary.As it can be seen in Table 1, simple two-parameter linear, exponential, or logarithmic fitting equations can be used to predict the concentration of the analytes.Nevertheless, the reactants are nonselective, and color variations are produced when they react with different analytes.Therefore, it is necessary to select the proper fitting function when a color variation is produced in some of the sensing membranes.This is accomplished in two steps as shown in Figure 5.
Firstly, by comparing the measured Euclidean colorimetric distances   for each reaction (four values for the four membranes in the sensor array) to the possible variation range of this parameter obtained in the calibration curve of the corresponding reaction, that is, if a value of  falls in the  variation range obtained for a given reaction, this reaction is considered as a possible solution.On the contrary, this reaction is discarded, as well as the presence of this analyte.After this process, several reactions may still be solutions of the problem case.For the final selection of the proper reaction, it is taken into account that, according to Table 1, each analyte produces at least two color variations in the sensor array; that is, there are at least two reactants that change their color when they are immersed in the analyte sample.This fact allows using at least two fitting equations for the determination of each analyte.If the result of these predictions, for the given values of , is the same, the obtained value of  is taken as the correct prediction of the corresponding analyte.We have checked that this procedure results in univocal solution in the analyzed framework.This separation algorithm has been implemented in the core of the Raspberry Pi board and it has been tested to predict the presence and concentration of the analytes, as it is detailed below.Good results are achieved, proving that the portable instrument presented here is useful to detect the presence of a variety of nitroaromatic compounds.

Validation and Specifications.
The resolution and sensitivity of the system have been theoretically calculated from the expressions of Table 1.The sensitivity  is evaluated as the derivative of the fitting function for the nitroaromatic compound : where () represents any of the fitting functions in Table 1.
The resolution can be evaluated from the sensitivity as the product of this parameter by the error in the determination of the variable  [33]: From ( 1), the resolution of the Euclidean distance  is And the resolution of the normalized color coordinates is calculated as where  = R, G, B and Δ = Δ ref is the resolution in the measurement of the color coordinate (R, G, or B).This is given by the resolution of the microcamera, which generates images with 8 bits per channel.Therefore, Δ is taken as 1/2 8 = 1/256.Taking into account that for the calculus of the analytes concentration at least two functions can be used, the resolution in its determination is considered as the worst case of these two possibilities.
The limit of detection (LOD) is calculated using the standard criteria, LOD =   + 3  , where   is the average blank signal and   is the standard deviation of the blank, which is determined using ten replicas [34].The values of sensitivity, resolution, and LOD achieved for the determination of the nitroaromatic compounds are listed in Table 2.The units of both the resolution and sensitivity are the same since the distance  used in (1)-( 3) is a dimensionless parameter.
As in every electronic system, some noise is present that can affect the measurement.In this case, two main sources of electronic noise should be considered.On one hand, small oscillations in the biasing of the white LEDs are used for the illumination of the sensors.On the other hand, the noise is induced by the CMOS microcamera, either electric or quantification noise.These sources of noise have been evaluated, resulting that the high stabilization in the biasing of the LEDs allows neglecting any fluctuation in the illumination; in addition the noise induced by the digital microcamera, including random noise, "fixed pattern" noise, and banding noise limits the specifications of the camera with a signal to noise ratio of 36 dB.
In addition to the electronic noise, some environmental noise in form of light interference can also affect the measurements.That is the reason to enclose the whole system in a dark box.
The presented specifications show a good performance of the developed instrument for the detection and determination of a variety of nitroaromatic compounds.A very good resolution, in the order of g/L, is achieved in every case, as well as very low LOD.The detection limits obtained are in the expected range for optical sensors, including colorimetric sensors [24,35] or fluorescence quenching based sensors [36][37][38].Although other techniques for nitroaromatics sensing provide better LODs below 10 ppb, such as surface plasmon resonance [39] or mass spectrometry [40], they require very complex instrumentation that makes the development of simple and portable systems based on them nonviable.
In order to demonstrate the proper functioning of the developed system several nitroaromatic standard solutions of known concentration were tested and their concentration was predicted using the presented system.The results are presented in Table 3, where the prediction value is the mean of four replicas, and the last row shows the standard deviation of these replicas.Although the results presented in Table 3 show accuracy lower than the expected one at the view of the resolution data of Table 2, this is due to the nonidealities in the sensor array preparation.This process is handmade, and misalignments, heterogeneities, shadows, and other effects can occur; therefore the response of the instrument is degraded.
As it can be observed, the recovery rate, defined as the ratio between the prediction and the real concentration, obtained from the samples used for testing purpose varies from 96.3% for 2-Cl-3,5-DNT at 5.0 mg/L to 106.0% for picric acid at 5 mg/L.Therefore, our measurement system is capable of determining accurately different nitroaromatic compounds with a low-cost and portable hardware displaying the results in a smartphone.

Conclusions
In this work a portable measurement system based on image processing for the detection and determination of nitroaromatic compounds, explosives or precursors of explosives, is presented.The prototype includes a Raspberry Pi board as the core of the instrument.This device controls a microcamera used for the acquisition of an image of the array of chemical nonselective sensors sensitive to several nitroaromatic compounds that show a color variation in the presence of these analytes.In addition, the image processing required to quantify the color variations in the sensing membranes is carried out in the Raspberry Pi board.Only four different sensors are used in the array for the detection of a large number of nitroaromatic compounds, from which eight are evaluated here.A simple and reliable algorithm for the detection and determination of single nitroaromatic compounds in mixtures is developed, therefore avoiding complex multivariate analysis techniques.The results obtained from the measurements are sent via WiFi to a remote user by means of a custom developed application for Android-based devices, such as tablets and smartphones.A high resolution in the order of g/L can be achieved with this instrument, assuming a good repeatability in the fabrication of the sensors array.Even in the case of handmade fabrication and deposition of the sensors array, where the repeatability is poor, a good prediction of nitroaromatic compounds has been achieved.

Figure 1 :Figure 2 :
Figure 1: Block diagram of the instrument showing both the portable reader unit and the Android mobile device with the programmed application to present the results.

Figure 4 :
Figure 4: Relationship between concentration of two analytes and measured Euclidean colorimetric distance for potassium hydroxide (a) and creatinine (b).

Figure 5 :
Figure 5: Flux diagram of the nitroaromatic identification and determination algorithm.

Table 2 :
Theoretical resolution, sensitivity, and limit of detection.