Freelancer

Write windows C/C++ code to quickly transform and display an image. Version 2  

Write windows C/C++ code to quickly transform and display an image. Version 2 is project number 108526
posted at Freelancer.com. Click here to post your own project.


| More Free Trial For New Buyers
 

Status: Awarded

Selected Providers: RGILHAM

Budget: $30-100

Created: 11/19/2006 at 11:36 EST

Bid Count: 7

Average Bid:
N/A

11/24/2006 at 11:36 EST

Project Creator: semquest
Employer Rating: 10/1010/1010/1010/1010/1010/1010/1010/1010/1010/10 (6 reviews)

Bid On This Project
 

Description

Rewrite my slow perl script in C/C++. Provide me with the SIMPLE source code and instructions on how to compile it in a "free" windows environment. I would prefer something like the windows express C++ environment that I can just take your C++ and compile and make it work. I don't want to have to buy a $1000 development environment. Or some free command line tools might be even better. Here is my perl script. Please provide me with a quote to do this job.

Your code will have the following properties.
It runs and follows my example of first opening sockets in ordrer
to get an image from the network device.
Then it takes the data and puts an image on the screen.
It does not use MSPAINT.EXE. I did that because it was increadibly
easy for me to get it working. Instead it opens a window and displays the image. The code should be able to then send out another command to get another image so that we can see the next image replace the old one. This would basically be video althought due to speed limitations we would really onlbe able to achieve a 2-5 frames per second perhaps. So I think displaying one image at a time would be acceptable.

# Camera image display Program
use IO::Socket::INET;
use Imager;
print "Cam Control";


$img = Imager->new(xsize=>1280, ysize=>1024); # imager object


# Open a receiver socket
$ReceiveSock=new IO::Socket::INET->new(LocalPort=>1233,Proto=>'udp') or die "error, cannot create receive socketn";
$newval = pack("I",3000000);
setsockopt($ReceiveSock, SOL_SOCKET, SO_RCVBUF, $newval);

# Open a send sockete
$SendSocket=new IO::Socket::INET->new(LocalAddr => 'localhost', LocalPort=>1234, Type=>SOCK_DGRAM, PeerPort=>1234,Proto=>'udp',
PeerAddr=>inet_ntoa(INADDR_BROADCAST),Broadcast=>1) or die "cannot create send socketn";

$msg='U'; # tells camera to send a frame
print "nSending message '",$msg,"'";
if($SendSocket->send($msg))
{
print ".....<done>","n";
}

$rowcount=0;
while($rowcount != 2048) { # of course this is stupid because it will lock up if we don't get all the rows for some reason
$ReceiveSock->recv($text,2000);
$row[$rowcount] = $text; # $text is actually a bunch of binary 8 bit words full of image YUYV data (YUV 4:2:2)
$rowcount++;
}
print "Got all the rows.n";

# convert to one row per row because each packet is actually half a row
for ($i=0; $i<1024; $i++) {
$row[$i] = substr($row[$i*2],2,1280) . substr($row[$i*2+1],2,1280);
}

# convert to RGB format
for ($j=0; $j<1024; $j++) {
@drow = unpack( 'C*' , $row[$j]);
for ($i=0; $i<640; $i++) {
# $setrow[$i*8] = $drow[$i*4] + int(1.14*($drow[$i*4+3]-128)); # red
# $setrow[$i*8+1] = $drow[$i*4] + int(-0.395*($drow[$i*4+1]-128)) - int(0.581*($drow[$i*4+3]-128)); # green
# $setrow[$i*8+2] = $drow[$i*4] + int(2.032*($drow[$i*4+1]-128)); # blue
# $setrow[$i*8+3] = 255;
# $setrow[$i*8+4] = $drow[$i*4+2] + int(1.14*($drow[$i*4+3]-128)); # red
# $setrow[$i*8+4+1] = $drow[$i*4+2] + int(-0.395*($drow[$i*4+1]-128)) - int(0.581*($drow[$i*4+3]-128)); # green
# $setrow[$i*8+4+2] = $drow[$i*4+2] + int(2.032*($drow[$i*4+1]-128)); # blue
# $setrow[$i*8+4+3] = 255;
$setrow[$i*8] = $drow[$i*4] + int(1.41*($drow[$i*4+3]-128)); # red
$setrow[$i*8+1] = $drow[$i*4] + int(-0.345*($drow[$i*4+1]-128)) - int(0.717*($drow[$i*4+3]-128)); # green
$setrow[$i*8+2] = $drow[$i*4] + int(1.78*($drow[$i*4+1]-128)); # blue
$setrow[$i*8+3] = 255;
$setrow[$i*8+4] = $drow[$i*4+2] + int(1.41*($drow[$i*4+3]-128)); # red
$setrow[$i*8+4+1] = $drow[$i*4+2] + int(-0.345*($drow[$i*4+1]-128)) - int(0.717*($drow[$i*4+3]-128)); # green
$setrow[$i*8+4+2] = $drow[$i*4+2] + int(1.78*($drow[$i*4+1]-128)); # blue
$setrow[$i*8+4+3] = 255;
}
for ($i=0; $i<5120; $i++) {
if ($setrow[$i] < 0) {$setrow[$i] = 0;}
if ($setrow[$i] > 255) {$setrow[$i] = 255;}
}
$setstring = pack ('C*',@setrow);
$img->setscanline(y=>$j,pixels=>$setstring);
# $img->setscanline(y=>$j,pixels=>pack("C*",(255,0,0,255,0,255,0,255,0,0,255,255,255,0,0,255)));
}

$img->write(file=>"testimg.bmp",type=>'bmp') or die "Cannot write image filen";

system ('mspaint testimg.bmp');

Messages Posted:1 View project clarification board Post message on project clarification board

Bid On This Project
 

If you are the project creator or one of the bidders Log In for more options

Bids are hidden by the project creator. Log in as the project creator or as one of the bidders to view bids. You will not be able to bid on this project if you are not qualified in one of the job categories. To see your qualifications click here.


    Bid on this Project