You can use the last line as this in Java CV:
opencv_core.cvRectangle(image, opencv_core.cvPoint(m,n), opencv_core.cvPoint(i,j), opencv_core.cvScalar(0,0,255,0), thickness, 8, 0);
Where the parameters mean:
opencv_core.cvRectangle(CvArr* img, CvPoint , CvPoint, CvScalar color, int thickness=1, int lineType=8, int shift=0)
and look at this Link for more information.
EDIT:
This is an example of finding contours:
cvFindContours(grayImage, memory, contours, sizeof(CvContour.class) , CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
Where the parameter mean:
cvFindContours(CvArr* image, CvMemStorage* storage, CvSeq** first_contour, int header_size=sizeof(CvContour), int mode=CV_RETR_LIST, int method=CV_CHAIN_APPROX_SIMPLE, CvPoint offset=cvPoint(0,0) )
For more information on the parameters, take a look at this Link, under FindContours
section.
You can also use the cvDrawContours
function, to draw the contours in the same way as we have used cvFindContours
function.
Take a look at this Link. It is a different post on this website in which the they have explained the use of finding contours in blob detection.
Hope This Helps.