- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @all,
I am currently working with the DE2 Dev.&Edu. Board with Cyclone II. In my project I am supposed to do a simple blob detection. The blobs are represented by white dots on black background. Since I am new I decided to start with the DE2_TV example to become familiar with the dataflow. If I did understand it correct the program does the manipulation of the data pixel-wise, which means that the information which pixel it is actually manipulating should be available. But I am a little bit confused which register does hold the information. I thought it should be the ports oCurrent_X and oCurrent_Y from the VGA_Ctrl module, but if thats the case why is the register 11 bit. This would allow a resolution of 2048x2048 (I know this is not the correct relation, it's just a example). But the output of the VGA has only a resolution of 640 x 480, so the coordinates of X and Y should be lay inbetween. Can someone help me here? Where can I get the X and Y coordinates for the pixels? regards, AlexLink Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, you are right. (oCurrent_X, oCurrent_Y) means coordinates for the pixels while (oVGA_BLANK==1). Never mind bit length.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do the coordinates change on every clock tick?
How can I make sure that I don't proceed a pixel twice or miss a pixel?module run_line_detection(CLK_27, CLK_50, iReset, iVGA_R, iVGA_B, iVGA_G, iPosX, iPosY, iThresh,
iVGA_BLANK, iDIG, oVGA_R, oVGA_B, oVGA_G, oTXD_DATA, oTXD_Start, ProceedingA_Run, previousPosX);
// INPUT
input iThresh;
input iVGA_R;
input iVGA_B;
input iVGA_G;
input iPosX;
input iPosY;
input CLK_27, iReset, CLK_50;
input iDIG;
input iVGA_BLANK;
// OUTPUT
output reg oVGA_R;
output reg oVGA_B;
output reg oVGA_G;
output reg oTXD_DATA;
output reg oTXD_Start;
// INTERNAL
parameter TRUE = 1'b1;
parameter FALSE = 1'b0;
output reg ProceedingA_Run; //flag to determine if pixel belongs to a run
output reg previousPosX;
reg previousPosY;
reg pixelPosX; //store start position of run on X-Axis
reg pixelPosY; //store start position of run on Y-Axis
reg pixelRunLength; //count number of pixels belonging to run
reg runRegister;//storage for detected runs
reg foundRun; //global counter for detected runs
reg writeBank; //flag to switch between write commands
reg frameCounter; //counter for frames 1-3 to change pointer on run-register in SRAM
reg counter;
always@(posedge CLK_27)
begin
if(!iReset)
begin
previousPosX = -1'd1;
previousPosY = -1'd1;
ProceedingA_Run = FALSE;
counter = 0;
end
if ( (iPosX <= 640) && (iPosY <= 480) )
begin
//value > Threshold => pixel belongs to blob
if((iVGA_R > iThresh) && (iVGA_G > iThresh) && (iVGA_B > iThresh) )
begin
oVGA_R = iVGA_R;
oVGA_G = iVGA_G;
oVGA_B = iVGA_B;
if(iVGA_BLANK)
begin
if(iPosX == (previousPosX +1))
begin
//Pixel is start point of a new run
if( ProceedingA_Run == FALSE )
begin
ProceedingA_Run = TRUE;
pixelPosX = iPosX;
pixelPosY = iPosY;
pixelRunLength = 0;
end
//increase number of counted pixels for current run
pixelRunLength = pixelRunLength + 1;
end
else
begin
//Actually proceeding a run, but current pixel does not belong to it the end of the run is reached
if( ProceedingA_Run == TRUE )
begin
ProceedingA_Run = FALSE;
//store run only if longer than 1 pixel
if( pixelRunLength > 1 )
begin
runRegister <= {pixelPosX, pixelPosY, pixelRunLength};
foundRun = TRUE;
end
else
begin
foundRun = FALSE;
end
end
end
end //end VGA_BLANK
end
else
begin
if(iVGA_BLANK)
begin
//Actually proceeding a run, but current pixel does not belong to it the end of the run is reached
if( ProceedingA_Run == TRUE )
begin
ProceedingA_Run = FALSE;
//store run only if longer than 1 pixel
if( pixelRunLength > 1 )
begin
runRegister <= {pixelPosX, pixelPosY, pixelRunLength};
foundRun = TRUE;
end
else
begin
foundRun = FALSE;
end
end
end //end VGA_BLANK
oVGA_R = 10'b0000000000;oVGA_G = 10'b0000000000;oVGA_B = 10'b0000000000;
end // threshold
end //if ( iPosX <= 640 && iPosY <= 480 )
else
begin
foundRun = FALSE;
end
if(foundRun == TRUE)
begin
foundRun = FALSE;
runRegister <= {8'd200, 8'd170, 8'd15};
end
previousPosX = iPosX;
previousPosY = iPosY;
//change register for runs if end of frame reached
if( (iPosX == 640) && (iPosY == 480 ))
begin
previousPosX = -1;
previousPosY = -1;
ProceedingA_Run = FALSE;
end
if(foundRun) begin
tmpRun = runRegister;
TXD_Buffer = {TXD_Buffer, tmpRun, 2'h0A};
TXD_Buffer_Flag = {TXD_Buffer_Flag, 5'b11111};
end
if(TXD_Buffer_Flag) begin
oTXD_Start = 1'b1;
oTXD_DATA = TXD_Buffer;
end
else
begin
oTXD_Start = 1'b0;
end
TXD_Buffer_Flag = {TXD_Buffer_Flag, 1'b0};
TXD_Buffer = {TXD_Buffer,8'b00000000};
end
endmodule
I have tested this code now with an wave input file. But every time when the procedure detects a pixel as above the threshold, the control variable proceedinga_run becomes undefined or represents 0 and 1 at the same time. Isn't possible to use register values in following iterations? Do they get lost? If I check for the previous position previousposx it works very well. Should I start from scratch or even change to SystemC ? I've invested now more than 2 months of work and don't make real efforts. Maybe doing it in Verilog was a bad decision?! thanks for your support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, for now I have skipped the method of Run-Length-Encoding based Blob detection and have reduced the algorithm to just compute a bounding box around the blob.
For simplification I just compute the bounding box around the blob for a image data that contains only a single blob. I still use the analog video in and it works! At the beginning I set min- and maxX -Y values and change them, dependend on the position of the pixel that I just proceed. I keep changing the values until the iPosX and iPosY values become (0,0) again, which means that a new frame has just started. The computed center point of the blob is displayed on the HEX-display and doesn't show any flickering. I will offer the source some time in the future, but I have to clean it up a little bit. So the next steps will be the extension of the blob detection to track multiple blobs in the same frame and then use some other interfaces of the DE2 board to provide 3 video inputs at the same time. I will keep updating this thread to provide my proceedings. cu Alex- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am just getting started with the DE2 board. I too am looking at the DE2_TV example and need to manipulate pixel information.
Could I receive the code where you are able to do this? Ultimately all I am looking to do is flip the image. I think your code can help me to start understanding how to do this. Thanks -M- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
sry for the late reply. I am busy working on a project. I have attached for you the whole project folder, which is basically the manipulated version of the DE2 demonstration. The interesting module for you should be run_line_detection.sv There I do a pixel-wise detection of binary large objects in a frame. The beginning of a frame is identified by the pixel coordinates. I think if you just delete most of the source an do the flipping of the pixel-values, then you are done. The source is very bad because I am still working on it. Just ask if something is unclear. regards, Alex- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Spellic
I am also using the same DE2_TV module for detecting any thing which came in the range of camera in the fixed background. Actually my project is to detect Face in the real time but for my convince i am supposing that what ever comes in camera range will be the face. Now i am confused in selecting the background. Please help me and also give me suggestion in getting started as i am new to this module and not have enough info. If you have some material please share me or if i can use your code then tell me how to use. Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi raosaifullah,
sorry for the late reply, I don't check the forum at regular intervals. Did you have a look at the source code I posted the last time? Is your camera connected to the analog interface? The problem with doing foreground-background segmentation is to know the background. The simplest way would be to use a black background (if your skin color is not black). This way you could just identify all relevant pixels by their color value. This is of course not very reliable, since you will loose some information that you want to have, like your eyes. But it's a start. Do you display the output on the VGA monitor? If yes you could extend the identification of the pixels by their color values, with changing the color of the relevant pixels to green for example. This way you could see how the approach works. good luck. Spellic- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your reply.
I have already done this what you have answered. i can detect any color by its pixel information. and now fixing black back ground. Now i need help in drawing rectangle around the detected face. Please help me in this. Also i want to save the pixel of detected face in SRAM of DE2 board at real time. Can you help me in this? Thanks Regards Rao Saifullah- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That might be kind of tricky.
To identiy the edge coordinates for the rectangle, process the image data and just keep the minimum and maximum coordinate values of the detected face. This allows you to create a bounding box around it. To draw the bounding box you need to store the image data in a frame buffer, when you search for the min-/max-values. Then you can use the bounding box data to just draw all pixels on the border of this bounding box in one color. (e.g. white) Hope that helps. Alex- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am just the beginner of the verilog code. After i get the min-/max-value, how can i draw the bounding box? Can anyone share the code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello guys,
i just work on my final year project for my degree.but my knowledge is less about coding / c / c + + / vhdl..can anybody xplain more about the number in [ ] the right below. for ur information, this some codes is Taken from the tutorial in TRDB_LTM_UserGuide_v1.23. input iTOUCH_IRQ; input [11:0] iX_COORD; // X coordinate form touch panel input [11:0] iY_COORD; // Y coordinate form touch panel input iNEW_COORD; // new coordinates indicate output [2:0] oDISPLAY_MODE; // displaed photo number tq.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to display the bouding box after computing the coordinate?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page