Upload Code
loading-left
loading loading loading
loading-right

Loading

Profile
No self-introduction
codes (2)
Real-time face detection using realsense SDk with
no vote
>EnableFace(); // Initialize pipeline  psm->Init(); //An example of a human face module  PXCFaceModule *faceModule = psm->QueryFace(); if (faceModule == NULL) { wprintf_s(L"Unabel to query FaceModule\n"); return 3; } //create an instance of a face tracking module of dynamic configuration PXCFaceConfiguration *cfg = faceModule->CreateActiveConfiguration(); if (cfg == NULL) { wprintf_s(L"Unabel to create FaceConfiguration\n"); return 4; } cfg->detection.isEnabled = TRUE;//his sentence can also comment out / / , does not affect the detection results //?????? cfg->EnableAllAlerts(); //???????????faceModule cfg->ApplyChanges(); //????????? PXCFaceData *facedata = faceModule->CreateOutput(); PXCImage *colorIm; PXCImage::ImageData color_data; PXCImage::ImageInfo color_info; while (psm->AcquireFrame(true) >= PXC_STATUS_NO_ERROR) { if (psm->AcquireFrame(true) < PXC_STATUS_NO_ERROR) break; //????????????? facedata->Update(); PXCCapture::Sample *sample = psm->QuerySample(); colorIm = sample->color; if (colorIm->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB24, &color_data) < PXC_STATUS_NO_ERROR) wprintf_s(L"????????\n"); color_info = sample->color->QueryInfo(); Mat color(Size(color_info.width, color_info.height), CV_8UC3, (void*)color_data.planes[0], color_data.pitches[0] / sizeof(uchar)); //?????????? pxcI32 nfaces = facedata->QueryNumberOfDetectedFaces(); //????????????? for (pxcI32 i = 0; i < nfaces; i++) { //?????????????? PXCFaceData::Face *trackedface = facedata->QueryFaceByIndex(i); PXCFaceData::DetectionData *detectiondata = trackedface->QueryDetection(); if (detectiondata == NULL) { wprintf_s(L"Unabel to get detection data\n"); return 5; } //????????????rect? PXCRectI32 rect; detectiondata->QueryBoundingRect(&rect); //PXCRectI32?opencv?Rect???? Rect cvrect = Rect(rect.x, rect.y, rect.w, rect.h); DrawRectangle(color, cvrect); //?????????????? stringstream ss; ss << i; string id = ss.str(); id = "ID:" + id; putText(color, id, Point(rect.x + rect.w / 2, rect.y - rect.h / 20), CV_FONT_HERSHEY_COMPLEX, 0.4, Scalar(255, 255, 0)); } colorIm->ReleaseAccess(&color_data); stringstream ss; ss << nfaces; string  num_faces = ss.str(); num_faces = num_faces + " faces in the field of view."; putText(color, num_faces, Point(color.rows / 20, color.cols / 40), CV_FONT_HERSHEY_COMPLEX, 0.5, Scalar(153, 51, 250)); psm->ReleaseFrame(); imshow("face_detection", color); waitKey(1); } facedata->Release(); cfg->Release(); psm->Close(); psm->Release(); }
khaleelkhan
2018-01-07
0
1
IMAGE PROCESSING X AND Y GRADIENT RETURNS DIRECTION
no vote
#include #include #include #include using namespace std; using namespace cv; // Computes the x component of the gradient vector // at a given point in a image. // returns gradient in the x direction int xGradient(Mat image, int x, int y) { return image.at (y - 1, x - 1) + 2 * image.at (y, x - 1) + image.at (y + 1, x - 1) - image.at (y - 1, x + 1) - 2 * image.at (y, x + 1) - image.at (y + 1, x + 1); } // Computes the y component of the gradient vector // at a given point in a image // returns gradient in the y direction int yGradient(Mat image, int x, int y) { return image.at (y - 1, x - 1) + 2 * image.at (y - 1, x) + image.at (y - 1, x + 1) - image.at (y + 1, x - 1) -
khaleelkhan
0000-00-00
0
1
No more~