Welcome! Log In Create A New Profile


Python image conversion help

Posted by ls7u 
Python image conversion help
May 30, 2013 04:37PM
Hi im trying to make a module to be able to send images from a Raspberry pi to a BV469-G with lenny firmware using python.

Bellow is part of my python script that gets image RGB and writes it out to the display using pil image lib.

I have two problems im stuck on ...

1). I can't find away to send image Height / width infomation in 16bit.

2). I am able to make out the image on the display but theres it is repeated three times and the colours are not correct.

any help or advice will be great , as im not getting any further with this.



import Image
import StringIO
import serial

ser = serial.Serial('COM20', 2000000)  

def send_image(image):
	pixels = image.load()
	ser.write('dicls\r\n')    # send cmd to accept image

	ser.write(chr(image.size[1]))      # send Height info
	ser.write(chr(image.size[0]))		 # send width info

	for y in xrange(image.size[1]):
		for x in xrange(image.size[0]):
			(r, g, b) = pixels[x, y]
			result = (r) |(g) |(b)

Re: Python image conversion help
May 30, 2013 06:45PM
the BV4629_g is the older version of the (BV4629_V2) BV514 but the image format is the same, here is the actual code that reads the serial port and displays the image:

// ******************************************************************************
// load bitmap using binary input, I think this should work
// bitmap format:
// <height:H><heigh:L><width:H><width:L>
// <r><g><b>......
// ******************************************************************************
void IL_bitmap(unsigned char x, signed int y)
int j, height, width;
unsigned char c;
COLOUR colr;

	if(I2Cf) height=i2c1_get()*256; else height=getch()*256;		// high byte
	if(I2Cf) height+=i2c1_get(); else height+=getch();		// lowbyte

	if(I2Cf) width=i2c1_get()*256; else width=getch()*256;		// high byte
	if(I2Cf) width+=i2c1_get(); else width+=getch();		// lowbyte

	// basic check
	if(height > MAXy) height=MAXy;
	if(width > MAXx) width=MAXx;
	IL_setAddress(x,y);	// set position and global
	while(height--) {
		for(j=0;j<width;j++) {
			if(I2Cf) colr.r=i2c1_get(); else colr.r=getch();
			if(I2Cf) colr.g=i2c1_get(); else colr.g=getch();
			if(I2Cf) colr.b=i2c1_get(); else colr.b=getch(); 
ignore the I2C stuff; as you can see 4 bytes are expected before the rgb information. The Python line:


will only send 1 integer or byte (I think), you need to split image.size[1] into its low and high bytes, possibly:
ser.write((image.size[1]) >> 8)
ser.write((image.size[1]) & 0xff)

Sorry, only registered users may post in this forum.

Click here to login