Application of Programming Language called Python for Diagnosis of Color of the target
Muskan Golchha1 , Aman Singh Negi2 , Amit Chauhan3 , Apoorva Jain4
1Student BCA, JEMTEC, Greater Noida
2Student BCA, JEMTEC, Greater Noida
3Student BCA, JEMTEC, Greater Noida
4Assistant Professor, Department of BCA, JEMTEC, Greater Noida
In the paper, we will be detecting colours of different object (bottle here) in various pictures using Python3.6, Open Source Computer Vision Library (OpenCV) and Numpy. The appropriate vital utilities are used for dispense of the illustration, which implicates loading them, and identifying a particular colour (green here) inside the given sample illustration. Few modifications can be applied to detect any other colour like blue, red, etc.
KEYWORDS: Vision, Python, Open CV
In this paper, we are going to detect the color of any object by applying the software computing language called Python. Python is a general purpose, high-level and dynamic object oriented language which is extensively used now a days. Its design philosophy insists on code legibility and has a structure that allows developers and users to write programs with fewer lines than some other programming languages. Python can accomplish quests on different platforms like Linux, windows, mac, etc. Python has many versions like Python 2.5, Python 3.7, etc.
We are here using Bottle as an object and will going to identify green color in it. We can take any object and can identify any color with the help of Python.
Things in the favour of the following software:-
• Superior precision in divisions under several illuminations.
• No wastage of time.
• It is not much responsive to background turbulence.
There are so many items we use on regular basis but it is very challenging to predict their colours. For example, flame i.e. fire, fire is comprised of many colours in it but we cannot conclude the presence of minute colours. That is why we bring out the notion of colour detection camera using the software -Python3.6, OpenCV and Numpy. This technique can identify a specific colour at a time. Our algorithm will detect green colour. We can modify the code to detect other colours.
Virtues of python:
1) Substantial Support Libraries
Most of the vastly used programming errands are previously composed into it that bounds the dimension of the codes to be written in Python.
2) Unification feature
Python unites the Enterprise Application Unification that makes it easy to prosper Web services by conjuring COM or COBRA constituents. It has authoritative mechanism abilities as it is originated through C, C++ or Java.
3) Improved programmer’s potency
The language has large maintenance of libraries and clear object-oriented designs that surge two to tenfold of programmer’s potency while operating with the languages like Java, VB, Perl, C, C++ and C#. With its robust procedural unification features, unit testing framework and embellish govern proficiencies subsidise towards the improved speed for utmost requests and great potency of requests.
4) Open source language
Another benefit of using python language for coding is that it is open source software i.e. free to use and have distributed and integrated environment. This feature allows us to create fresh codes and modules.
1) Trouble in using other languages
The Python admirers become so addicted to its features and its huge libraries, so they suffer from learning or functioning on other computing languages. Python experts may see the asserting variable “types”, semantic necessities of adding curl brackets or semi colons as a difficult task.
2) Fragile in mobile computing
Python has made its existence on numerous server platforms even in many software businesses but it still seems to be fragile in mobile computing. That’s why a minor number of mobile requests are built in it like Carbonnelle.
3) Run time errors
It obliges more testing time, and shows inaccuracies during runtime.
4) Lagging database approach layers
As compared to the widespread technologies like JDBC and OBDC, the Python’s database approach layer is found to be impoverished and old. However, it cannot be used to have a good and smooth interaction with compound inherited data.
WAY TO OPENCV:
As the name defines OpenCV is Open source computer vision library of computing functions primarily designed for real-time computer vision. Primitively developed by Intel, it was later financed by Willow Garage then Itseez (which was later gained by personal exertion by Intel). The library is multiplatform and we can use it for free under the open-source BSD license. The library is written in C and C++ and works on Linux, Windows and provides junction for Python, Ruby, Matlab and other languages. OpenCV library comprises of plentiful innovative math functions, image handling purposes, and computer vision purposes that extent many areas in vision.
A. Basic Class-
OpenCV 1.0 contains the succeeding five modules :
1) CxCore: Some basic functions (several data types and basic procedures, etc.).
2) CV: Contains image handling and computer vision purpose (image processing, structure analysis, motion analysis, and object tracing, pattern recognition, and camera correction).
3) CvAux: Some new functions (View Morphing, Three-dimensional Tracking) 4) High GUI: Contains user interface GUI
5) CvCam: Camera interface (After OpenCV 1.0 version, CvCam will be entirely detached.).
2. Enlightenment over the code:
In order to execute dynamic operations, the gadget’s web camera is used. To record or capture a video, it is must to build a Video Capturing item or object. Its dispute can be the device’s catalogue moreover the title of a video file. Device’ catalogue is just the numeral to stipulate camera. Single camera can be linked by passing False and when we want to link another camera we will pass true and so on. Then, we can capture it frame-by-frame. At last, don’t fail to recall freeing the capture. And if anyone wants to use this technique on any picture it can be done by some alterations in the code.
The inestimable loop is used so that the web camera records the activity in every case and remains opened until we are not done with the recording.
After taking the live stream frame by frame we will convert all the frames to BGR to HSV. There are more than 150 are available in OpenCV. To modify the colour, we use the function cv2.cvtColor (input_image, flag) where flag controls the conversion type. To convert BGR to HSV, we use cv2.COLOR_BGR2HSV.
In stipulating the scale, we have stipulated the scale of green colour. We can pass the scale of any coloR.
The mask is mainly crafting certain section of the image. There are some as follows:
Here we are constructing a mask which includes an object of green colour. Bitwise and operator is used on the inserted image and the threshold image so that only green coloured stuffs are emphasized and stored in result. Using imshow () we can exhibit the frame, result and the mask on discrete windows systems.
Display the Result:
Since imshow () has high GUI and is essential to request wait key frequently, in order to practise its event loop.
The wait Key () waits for key event for “interval” or a “delay”. If we don’t call, the wait key (), high GUI will not route windows event like input, resizing, etc.
Brief of the procedure:
1. Take all the frames of the film.
2. Transform all frames from BGR to HSV.
3. Threshold the HSV image  for the scale of green colour.
import numpy as np
ret, frame = device.read()
lower_range = np.array([33″,80″,40])
upper_range = np.array([102″,255″,255])
mask = cv2.inRange(hsv, lower_range, upper_range)
if cv2.waitKey(1) == 27:
1) By using OpenCV with python we will code for specific colour (here is green).
2) Web camera (0) is used to record the frames. Now the infinite loop will start.
3) When while (true) is passed then it will capture each and every frame.
4) We will convert BGR colour space to HSV colour space.
5) After this we will define a scale to green colour in HSV.
6) A mask of green colour will be created and the items are found in the frame.
7) Because of the use of bitwise_and operator and masking technique only green color objects will be spotted and stored in the result.
8) The imshow () will help us to see the result and the frame.
9) After getting the results destroy the high GUI windows and release the recorded frame.
In the result, three windows will open:
1. Main window that has the actual object.
2. Second window which will show the object with black and white colour. But white colour will appear on the green colour object.
3. Third window will show the green colour of the object.
Computer visualization can be used to resolve the most Interesting complications with extreme superiority. In This paper, by using Python we have detected the outlines, figures & colours of the given illustration properly.
This idea can be used or installed in CCTV cameras. It will be beneficial for detecting several objects, vehicles and human beings also. The concept Object detection will help in protection and safeguarding.
6. FUTURE WORK
In future Python can be used for –
Biometric consists of everybody’s thumbprint, Retina Examine iris design, heartbeat, etc. Any of this natural Exclusive quality can be used to lock or open many Systems.
The philosophy of Object Recognition is also used in Health and medicinal field where it’s used to identify infections like cancer.
3)Optical character recognition (OCR):
The official papers that are typed and scanned, handwritten or printed characters  can be recognized using object detection.
7. REFERENCES :
 TIOBE Software Index (2011). “TIOBE Programming Community Index Python”.
 “Programming Language Trends – O’Reilly Radar”. Radar.oreilly.com. 2 August 2006.
 “The RedMonk Programming Language Rankings: January 2011 – tecosystems”. Redmonk.com.  Summerfield, Mark. Rapid GUI Programming with Python and Qt.
The Active Badge Location System by Roy Want, Andy Hopper, Veronica Falcão and Jonathan Gibbons Olivetti Research Ltd. (ORL) Cambridge, England.
 CS 268: Lecture 20 Classic Distributed Systems: Bayou and BFT by Ion Stoica Computer Science Division Department of Electrical Engineering and Computer Sciences University of California, Berkeley Berkeley, CA 94720-1776