Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Edge detection, which parameter used for get autofocus working ?

Status
Not open for further replies.

abimann

Member level 4
Joined
Jun 21, 2016
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
673
Hello everyone PlS help !!!

Is that is same FrameEdgeCount with summa in a following code ? or how to make this ?
Frame edge count i found in youtube in 2:41 . I want to use it to make autofocus for my camera. Code from github ,

Code:
 architecture Behavioral of edge_sobel is
begin
	edge_sobel: process (pclk_i)
	
		variable summax, summay : std_logic_vector(10 downto 0);
		variable summa1, summa2 : std_logic_vector(10 downto 0);
		variable summa          : std_logic_vector(10 downto 0);
		
	begin  
		if (pclk_i'event and pclk_i = '1') then 
			
			rsync_o <= rsync_i;
			fsync_o <= fsync_i;
			
		if fsync_i = '1' then			
			if rsync_i = '1' then			
															-- x2
				summax:=("000" & pdata3)+("00" & pdata6 & '0')+("000" & pdata9)
					-("000" & pdata1)-("00" & pdata4 & '0')-("000" & pdata7);
															-- x2
				summay:=("000" & pdata7)+("00" & pdata8 & '0')+("000" & pdata9)
					-("000" & pdata1)-("00" & pdata2 & '0')-("000" & pdata3);
				
				-- Here is computed the absolute value of the numbers
				if summax(10)='1' then
					summa1:= not summax+1;
				else
					summa1:= summax;				
				end if;

				if summay(10)='1' then
					summa2:= not summay+1;
				else
					summa2:= summay;
				end if;
				
				summa:=summa1+summa2;
				
				summa_out<=summa;
				-- Threshold = 127
				if summa>"00001111111" then			
					pdata_o<=(others => '1');
				else 
					pdata_o<=summa(DATA_WIDTH-	1 downto 0);
				end if;
				
			END IF;
		end if;
Sobel fileter result , has some display problem cannot find out why. frameedgesumm.png
 

Attachments

  • IMG_2746.jpg
    IMG_2746.jpg
    502.2 KB · Views: 131

I dont understand the quesiton? can you please rephrase exactly what the problem is?
 

I dont understand the quesiton? can you please rephrase exactly what the problem is?

what value or what variable need to be use from edge detection code to send to servo or stepper motor controller to regulate auto focus ?
 

Attachments

  • motorizedZoom.png
    motorizedZoom.png
    194.5 KB · Views: 127
  • IMG_2746.jpg
    IMG_2746.jpg
    502.2 KB · Views: 121

Hi,

you may focus on background and you may focus on foreground. Thus you need to specify the area of interest.

Generally sharper edges means a higher frequency range.
Thus a high pass filter (or differentiation) plus some kind of calculatein about the high pass filtered ampliltude (like RMS) should do the job.

I assume if you search the internet you will find optimized focus caclulation methods.

Klaus
 

what value or what variable need to be use from edge detection code to send to servo or stepper motor controller to regulate auto focus ?

Pulse width modulation? Surely your stepper motor controller has a datasheet?

I would imagine you have some threshold from the sorbel filter. For example here we have a blob - window - of values exceeding threshold, therefore we adjust motor, until blob is sharp line.
 

no good experience in vhdl
when so many edges , it mean camera best focused, so I think need to just invert data and summ for every frame.. pls help with code .
when video = '1' video is std_logic
x_int integer range from 0 to 639
y_int integer range from 0 to 479
DATA_O - output from sobel filter
sim is unsigned
sim_out also unsigned
data_int <= to_unsigned(DATA_O);
process(clk26)
begin
if rising_edge(clk26) then
if video = '1' then
sim:=sim+data_int;
if y_int = 478 then
sim_out<=sim;
if y_int = 479 then
sim:=(others => 0);
sim_out:=(others => 0);
end if;
end if;
end if;
end if;
end process;
 

Woah, hold up.

Do you know the difference between variables and signals?

Also please use indentation. That way you can see logical errors - see nested if below


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
data_int <= to_unsigned(DATA_O); 
 process(clk26)
 begin
   if rising_edge(clk26) then
     if video = '1' then
       sim:=sim+data_int;  -- This is a variable assignment? Is your variable local/shared?.
       if y_int = 478 then
         sim_out<=sim;
         if y_int = 479 then -- This is a nested IF, It is only analysed if parent if is true. Since parent implies this is false it will never execute.
           sim:=(others => 0);
           sim_out:=(others => 0);
         end if;
       end if;
     end if;
   end if;
 end process;



Look at comments I've placed inside
 

Hello , from VGA controller coming x and y , x is rows which is from 0 to 639 and y is a row's summ of x, from 0 to 479, so it need to find summ of all Data_int when video is equal to 1,
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top