# RGB values by Ip Camera

**URL:** <https://forum.inductiveautomation.com/t/rgb-values-by-ip-camera/12452>\
**Category:** General Discussion\
**Created:** [December 10, 2016, 11:46am UTC](https://forum.inductiveautomation.com/t/rgb-values-by-ip-camera/12452 "2016-12-10T11:46:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaoloPK](https://avatars.discourse-cdn.com/v4/letter/p/ba8739/32.png) [@PaoloPK](https://forum.inductiveautomation.com/u/PaoloPK)\
**Post date:** [December 10, 2016, 11:46am UTC](https://forum.inductiveautomation.com/t/rgb-values-by-ip-camera/12452/1 "2016-12-10T11:46:10Z")

</div>

Hi,  
you can get the RGB values of an image produced by Ip Camera for the control process ?  
I have a timer and every 60 seconds do a image.

Script to timer

```auto
if (event.source.value == 30):
	image = system.print.createImage(event.source.parent.parent.getComponent("CAMERA_IN"))
	project.myfuncs.myimage(image)
```

In the Script Library i have create a myfuncs:

```auto
import datetime
import time
from java.io import *
from java.awt import *
from java.awt import Component
from java.awt import Color
from javax.imageio import ImageIO
from java.awt.image import BufferedImage
from java.io import ByteArrayOutputStream
from java.io import ByteArrayInputStream
from javax import imageio
from java.util import Arrays

# save image to folder
def myimage(image):
	now = datetime.datetime.now()
	mytime1 = now.strftime("%d-%m-%Y_%H-%M-%S")
	mytime = str(mytime1)
	baos = ByteArrayOutputStream()
	ImageIO.write(image, "jpg", baos)
	baos.flush()
	imageInByte = baos.toByteArray()
	baos.close()
	system.file.writeFile(r"C:\\temp\\Test_"+mytime+".jpg", imageInByte)
	mypixel(image)

# cicle image for all pixel to width and height
def mypixel(image):
	w = image.getWidth()
	h = image.getHeight()
	pixelData = (w * h)
	count = 0
	for i in range(1, h):
		for j in range(1, w):
			count = count + 1
			myList = getPixelData(image, i, j, count)

	print "Value out: ", myList
	
# return rgb value
def getPixelData(image, x, y, count):
	argb = image.getRGB(y, x) #image.getRGB(col, row)
	alpha = (argb>>24) & 0xff
	red = (argb>>16) & 0xff
	gre = (argb>>8) & 0xff
	blu = (argb) & 0xff
	lux = (0.299 * red) + (0.587 * gre) + (0.114 * blu)
	myList = [alpha, red, gre, blu, lux, count]
	return myList
```

There is an error because I get:  
Value out: [255, 255, 255, 255, 255.0, 76944]

can you help me, thanks

---

<div class="post-metadata">

**Author:** ![anna](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@anna](https://forum.inductiveautomation.com/u/anna)\
**Post date:** [February 23, 2017, 6:32pm UTC](https://forum.inductiveautomation.com/t/rgb-values-by-ip-camera/12452/2 "2017-02-23T18:32:24Z")

</div>

PaoloPK, have you tried printing out the variables used in calculations? That should help you narrow down where the issue is.  
Also, have you tested this code for an image? For an image or video stream outside of Ignition?
