나는 어떤 색의 레이저 광 점을 감지하려고 laser.and 그 코드 만 RED 완벽하게 실행 OpenCV Android Track laser dot안드로이드
여기에서 몇 가지 기준 코드를 수행 한 색상 감지 및 나는 레이저 도트 탐지의 어떤 색깔을 원한다.
OpenCV에서 새로 생겼습니다.
여기에 내가 지금까지 무엇을했는지 : 당신이 게시
Mat originalFrame= new Mat();
Mat frame = new Mat();
cvf.rgba().copyTo(originalFrame);
cvf.rgba().copyTo(frame);
Mat frameH;
Mat frameV;
Mat frameS;
mRgba = cvf.rgba();
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Mat hierarchy = new Mat();
// Mat frameS;
// Convert it to HSV
Imgproc.cvtColor(frame, frame, Imgproc.COLOR_RGB2HSV);
// Split the frame into individual components (separate images for H, S,
// and V)
mChannels.clear();
Core.split(frame, mChannels); // Split channels: 0-H, 1-S, 2-V
frameH = mChannels.get(0);
frameS = mChannels.get(1);
frameV = mChannels.get(2);
// Apply a threshold to each component
Imgproc.threshold(frameH, frameH, 155, 160, Imgproc.THRESH_BINARY);
// Imgproc.threshold(frameS, frameS, 0, 100, Imgproc.THRESH_BINARY);
Imgproc.threshold(frameV, frameV, 250, 256, Imgproc.THRESH_BINARY);
// Perform an AND operation
Core.bitwise_and(frameH, frameV, frame);
//
// Core.bitwise_and(frame,frameS,frame);
Imgproc.findContours(frame, contours, hierarchy, Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_SIMPLE, new Point(0, 0));
hierarchy.release();
for (int contourIdx=0; contourIdx < contours.size(); contourIdx++)
{
// Minimum size allowed for consideration
MatOfPoint2f approxCurve = new MatOfPoint2f();
MatOfPoint2f contour2f = new MatOfPoint2f(contours.get(contourIdx).toArray());
//Processing on mMOP2f1 which is in type MatOfPoint2f
double approxDistance = Imgproc.arcLength(contour2f, true)*0.02;
Imgproc.approxPolyDP(contour2f, approxCurve, approxDistance, true);
//Convert back to MatOfPoint
MatOfPoint points = new MatOfPoint(approxCurve.toArray());
// Get bounding rect of contour
Rect rect = Imgproc.boundingRect(points);
Imgproc.rectangle(originalFrame, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 0, 255), 3);
}
코드를 시작하면 찾고있는 레이저의 색을 알 수 있습니까? 예를 들어, "이제는 적색 레이저 대신 청색 레이저를 감지하고 싶습니다"라고 설정하거나 어떤 이미지에서 어떤 레이저를 검출하고 싶습니까? 첫 번째 사례는 매우 쉽고, 두 번째 사례는 까다 롭고 오류가 발생하기 쉽습니다. 어떤 다른 가정이 있습니까 (예 : 장면/작업) – Micka
헤이 @ 미카, 레이저의 색상은 빨강, 초록, 파랑, 보라색과 비슷할 수 있습니다 ... 그리고 나는 라이브 카메라 프레임에서 그것을 감지하고 싶습니다. 영상. 이걸 좀 도와 주실 수 있습니까? 감사. –
라이브 비디오도 이미지입니다. 나는 사용자가 런타임 동안 가능한 레이저 색상을 제한 할 수 있는지 여부를 알고 싶었거나 동시에 모든 레이저 색상을 감지하려고하는지 여부를 알고 싶었습니다 (훨씬 더 어려울 것입니다). 예를 들어 사용자는 "이제 보라색 레이저 만 감지하고 싶습니다. 발표자가 사용하는 레이저가 보라색이고 다른 레이저는 없을 것입니다."라는 설정을 변경할 수 있습니다. 우리는 귀하의 신청서를 모르기 때문에 이러한 종류의 가정이 유효한지 여부를 알 수 없습니다. – Micka