[Gambas-user] jpeg performance

nando nando_f at ...951...
Tue Jan 3 20:02:14 CET 2006


My experience is that using STRETCH is slower.
(but if you need to use it - you need to use it)
The picture requires more processing to alter/stretch.

You may want to try the following idea so that it is threaded.
Consider...
Shelling to a 3-line Shell script (a different one for each camera):

Line 1: RMDIR /tmp/cam1.done
Line 2: wget 'http://127.0.0.1/cgi-bin/nph -zms?mode=single&monitor=2&scale=100'
-O /tmp/cam1.jpg 
Line 3: MKDIR /tmp/cam1.done

..then in your GAMBAS program you have

WHILE ActiveUpdate = TRUE 

SHELL "script for camera number 1"   'no WAIT..these 4 run independently
SHELL "script for camera number 2"
SHELL "script for camera number 3"
SHELL "script for camera number 4"

WAIT 0.1

IF Exist "/tmp/cam1.done" THEN  ' the folder created is a signal that
                                ' the script finished getting the picture
  imagee1 = NEW Image
  imagee1.Load ("/tmp/cam1.jpg")
  image1=imagee1.Stretch (desktop.Width /2,desktop.Height /2 ,[TRUE])
ENDIF

..repeat the if EXIST for other three.

WEND


SUB StopUpdating_Click()   'button called StopUpdating

 ActiveUpdate = False
END

'Each 4 Shells runs indendently simultaneously..that is a speedup
...see how fast that goes??

-Fernando


---------- Original Message -----------
From: "James Wilson" <JamesWilson at ...1288...>
To: <gambas-user at lists.sourceforge.net>
Sent: Tue, 3 Jan 2006 18:00:49 -0000
Subject: [Gambas-user] jpeg performance

> HI all
> 
> I have the following code
> 
> DIM image1 AS image 
> DIM imagee1 AS Image 
> DIM image2 AS image 
> DIM imagee2 AS Image 
> DIM image3 AS image 
> DIM imagee3 AS Image 
> DIM image4 AS image 
> DIM imagee4 AS Image 
> SHELL "wget 'http://127.0.0.1/cgi-bin/nph-
> zms?mode=single&monitor=2&scale=100' -O /tmp/cam1.jpg " WAIT  SHELL 
> "wget 'http://127.0.0.1/cgi-bin/nph-
> zms?mode=single&monitor=3&scale=100' -O /tmp/cam2.jpg " WAIT  SHELL 
> "wget 'http://127.0.0.1/cgi-bin/nph-
> zms?mode=single&monitor=4&scale=100' -O /tmp/cam3.jpg " WAIT  SHELL 
> "wget 'http://127.0.0.1/cgi-bin/nph-
> zms?mode=single&monitor=5&scale=100' -O /tmp/cam4.jpg " WAIT
> 
> 'image1= NEW Picture 
> 'image1.Load ("/tmp/cam1.jpg")
> imagee1 = NEW Image
> imagee1.Load ("/tmp/cam1.jpg")
> image1=imagee1.Stretch (desktop.Width /2,desktop.Height /2 ,[TRUE])
> imagee2 = NEW Image
> imagee2.Load ("/tmp/cam2.jpg")
> image2=imagee2.Stretch (desktop.Width /2,desktop.Height /2 )
> imagee3 = NEW Image
> imagee3.Load ("/tmp/cam3.jpg")
> image3=imagee3.Stretch (desktop.Width /2,desktop.Height /2 )
> imagee4 = NEW Image
> imagee4.Load ("/tmp/cam4.jpg")
> image4=imagee4.Stretch (desktop.Width /2,desktop.Height /2 )
> 
> 'DIM image1 AS   imagee1.Stretch (320,240,[TRUE]) AS image
> 'picturebox1.picture = image1
> 
> 'picturebox2.picture= image1
> 'drawingarea1.Mask=picture["/tmp/cam1.jpg"]
> draw.Begin(drawingarea1)
> draw.Image(image1,0,0)
> draw.End 
> draw.Begin(drawingarea2)
> draw.Image(image2,0,0)
> draw.End 
> draw.Begin(drawingarea3)
> draw.Image(image3,0,0)
> draw.End 
> draw.Begin(drawingarea4)
> draw.Image(image4,0,0)
> draw.End 
> fps = fps+1
> label1.Text = "refresh rate at " & fps &" fps"
> imagee1.Clear 
>  image1.Clear 
>  imagee2.Clear 
>  image2.Clear 
>  imagee3.Clear 
>  image3.Clear 
>  imagee4.Clear 
>  image4.Clear
> 
> This is set on a timer to be called repeatedly. I have used wget as 
> its the only way i know to get images from a url. The string above 
> will download a jpeg approx 60k is size. They are pictures from my 
> cctv system. Now the system runs but very slowly. I first tried 
> picture boxes but these flickered badly and then i found the 
> drawingarea. Im very new to programming, but have had some success 
> with vb.net. What am i doing wrong as the refreshes take 3-4 seconds. 
> I am hoping to achive 5 refreshes per second.
> 
> Regards
> James
------- End of Original Message -------





More information about the User mailing list