I’m having trouble adding rectangles to an image using OpenCV. I think part of the problem is the way I’m attempting to do it but I can’t figure out a better way to do it.
cs::UsbCamera camera1 = CameraServer::GetInstance()->StartAutomaticCapture("cam0",0);
camera1.SetResolution(200, 200);
cs::CvSink cvsink = CameraServer::GetInstance()->GetVideo("cam0");
cs::CvSource outputStreamStd = CameraServer::GetInstance()->PutVideo("eh", 200, 200);
cv::Mat source;
cv::Mat Output;
cv::Point pt1 = cv::Point(20,-1);
cv::Point pt2 = cv::Point(80,200);
cvsink.GrabFrame(source);
cv::rectangle(source,pt1,pt2,cv::Scalar(255,0,255),5,8,0);
cs::UsbCamera camera2 = CameraServer::GetInstance()->StartAutomaticCapture("cam1",1);
camera2.SetResolution(200, 200);
cs::UsbCamera camera3 = CameraServer::GetInstance()->StartAutomaticCapture("cam2",2);
camera3.SetResolution(200, 200);
this is what I currently have but I can’t figure out how to get the processed image onto the smart dashboard.
Thanks in advance
I would recommend a more low-tech way:
Draw the box in something like Paint.NET . Make the background transparent. Save in an image file that SmartDashboard supports. Add that picture to smart dashboard and place it in front of your video image at the appropriate location.
We did this last year and it worked very well.
Praj
February 22, 2017, 9:04pm
3
Robodragons4630:
I’m having trouble adding rectangles to an image using OpenCV. I think part of the problem is the way I’m attempting to do it but I can’t figure out a better way to do it.
cs::UsbCamera camera1 = CameraServer::GetInstance()->StartAutomaticCapture("cam0",0);
camera1.SetResolution(200, 200);
cs::CvSink cvsink = CameraServer::GetInstance()->GetVideo("cam0");
cs::CvSource outputStreamStd = CameraServer::GetInstance()->PutVideo("eh", 200, 200);
cv::Mat source;
cv::Mat Output;
cv::Point pt1 = cv::Point(20,-1);
cv::Point pt2 = cv::Point(80,200);
cvsink.GrabFrame(source);
cv::rectangle(source,pt1,pt2,cv::Scalar(255,0,255),5,8,0);
cs::UsbCamera camera2 = CameraServer::GetInstance()->StartAutomaticCapture("cam1",1);
camera2.SetResolution(200, 200);
cs::UsbCamera camera3 = CameraServer::GetInstance()->StartAutomaticCapture("cam2",2);
camera3.SetResolution(200, 200);
this is what I currently have but I can’t figure out how to get the processed image onto the smart dashboard.
Thanks in advance
Are you running this on a co processor? The jetson or pi? In cameraServer I would suggest using mjpeg streamer.