This paper describes the development of an optical sensor device using a smartphone and a homemade dark chamber built with recycled materials. This low cost instrument was employed in the development of multivariate image regression methods for the determination of the azo dye allura red in hard candies. To build the models, 238 candy samples of four flavors and different brands and batches were used. Firstly, a multivariate calibration model using RGB histograms and partial least squares (PIS) was built. This model provided high prediction errors, which were attributed to the presence of textural variations in the images. Then, a more complex image analysis methodology that incorporates spatial information, and consists of preprocessing by a two-dimensional fast Fourier transform followed by multi-way calibration with N-way PLS, provided better results, decreasing the prediction errors around 25-35%. The final model was submitted to a complete multivariate analytical validation, being considered precise, linear, sensitive and unbiased. The analytical range was established between 22.9 and 78.8 mg kg(-1) of allura red. Root mean square errors of calibration (RMSEC) and prediction (RMSEP) of 4.8 and 6.1 mg kg(-1) were estimated. The developed method is simple, rapid, and nondestructive.