필터 지우기
필터 지우기

problem with Snapshot on webcam

조회 수: 6 (최근 30일)
muhammad faiz
muhammad faiz 2017년 8월 16일
답변: ProblemSolver 2023년 6월 27일
Hi everyone, I have problem with the snapshot syntax. so, basically, i have this project which use laser distances and camera/webcam for detection. the process is something like this and it is in real time: when laser sensors detect the obstacles, it will instruct camera to get a snapshot of the scenes. Then, as the laser sensors move closer to the obstacles, it will take another snapshot of the scenes. so, the problem is, i always get similar image between snapshot scenes 2 and snapshot scenes 1. I do not know what happen, seems like the camera stuck in viewing the scenes. The snapshot scenes 2 and Snapshot scenes 1 supposed to be different image due to different distance detected. can somebody tell me what is going on? hope you guys understand the problem.
Thank you
  댓글 수: 2
Image Analyst
Image Analyst 2017년 8월 16일
Understood, but there's no way we can fix it. We don't have your code or your laser/camera setup.
muhammad faiz
muhammad faiz 2017년 8월 16일
end
Radio = serial('COM3','BaudRate',9600); % from the distance sensor
fopen(Radio);
Nvalues=1000000000;
Mvalues=1000000000;
k=0;
w=0;
cam=webcam('ManyCam Virtual Webcam');
cam.Resolution='640x360';
while k<Nvalues
Lidar_distance = fscanf(Radio,'%f');
if (Lidar_distance<=8.1)
Image_Ref=snapshot(cam);
while w<Mvalues
second_distance=fscanf(Radio,'%f');
if (second_distance<=7.1)
Image_Current=snapshot(cam);
break;
end
display(second_distance)
w=w+1;
end
end
display(Lidar_distance)
k=k+1;
end
______________________ this is my code (simplified version)

댓글을 달려면 로그인하십시오.

답변 (1개)

ProblemSolver
ProblemSolver 2023년 6월 27일
Based on the snippet of the code that you provided:
1) Delay in capturing the second snapshot: It is possible that there is a delay in capturing the second snapshot, causing the camera to capture the same sense as the first snapshot. To address this you can introduce a delay before capturing the snapshot using 'pause' function. For example, you can add 'pause(1)' before capturing 'Image current' to introduce a 1-second delay (Something like this)
if (Lidar_distance <= 8.1)
Image_Ref = snapshot(cam);
while w < Mvalues
second_distance = fscanf(Radio, '%f');
if (second_distance <= 7.1)
pause(1); % Add a delay of 1 second
Image_Current = snapshot(cam);
break;
end
display(second_distance)
w = w + 1;
end
end
2) Camera settings or autofocus: The camera settings or autofocus functionality may be affecting the captured images. Ensure that the camera is properly focused and that the autofocus is disabled if it's causing any issues.
3) Image processing issues: If the captured images still appear similar, it could be due to image processing issues. Make sure you are correctly displaying the captured images (Image_Ref and Image_Current) and not accidentally displaying the same image twice.
Additionally, you can print out the image dimensions (size(Image_Ref) and size(Image_Current)) to verify if the images have different dimensions. If they have the same dimensions, it would suggest that the camera is capturing the same scene for both snapshots.
I hope this helps!

카테고리

Help CenterFile Exchange에서 Labeling, Segmentation, and Detection에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by