void simpleFluidEmitter::omniFluidEmitter( MFnFluid& fluid, const MMatrix& fluidWorldMatrix, int plugIndex, MDataBlock& block, double dt, double conversion, double dropoff ) //============================================================================== // // Method: // // simpleFluidEmitter::omniFluidEmitter // // Description: // // Emits fluid from a point, or from a set of object control points. // // Parameters: // // fluid: fluid into which we are emitting // fluidWorldMatrix: object->world matrix for the fluid // plugIndex: identifies which fluid connected to the emitter // we are emitting into // block: datablock for the emitter, to retrieve attribute // values // dt: time delta for this frame // conversion: mapping from UI emission rates to internal units // dropoff: specifies how much emission rate drops off as // we move away from each emission point. // // Notes: // // If no owner object is present for the emitter, we simply emit from // the emitter position. If an owner object is present, then we emit // from each control point of that object in an identical fashion. // // To associate an owner object with an emitter, use the // addDynamic MEL command, e.g. "addDynamic simpleFluidEmitter1 pPlane1". // //============================================================================== { // find the positions that we need to emit from // MVectorArray emitterPositions; // first, try to get them from an owner object, which will have its // "ownerPositionData" attribute feeding into the emitter. These // values are in worldspace // bool gotOwnerPositions = false; MObject ownerShape = getOwnerShape(); if( ownerShape != MObject::kNullObj ) { MStatus status; MDataHandle hOwnerPos = block.inputValue( mOwnerPosData, &status ); if( status == MS::kSuccess ) { MObject dOwnerPos = hOwnerPos.data(); MFnVectorArrayData fnOwnerPos( dOwnerPos ); MVectorArray posArray = fnOwnerPos.array( &status ); if( status == MS::kSuccess ) { // assign vectors from block to ownerPosArray. // for( unsigned int i = 0; i < posArray.length(); i ++ ) { emitterPositions.append( posArray[i] ); } gotOwnerPositions = true; } } } // there was no owner object, so we just use the emitter position for // emission. // if( !gotOwnerPositions ) { MPoint emitterPos = getWorldPosition(); emitterPositions.append( emitterPos ); } // get emission rates for density, fuel, heat, and emission color // double densityEmit = fluidDensityEmission( block ); double fuelEmit = fluidFuelEmission( block ); double heatEmit = fluidHeatEmission( block ); bool doEmitColor = fluidEmitColor( block ); MColor emitColor = fluidColor( block ); // rate modulation based on frame time, user value conversion factor, and // standard emitter "rate" value (not actually exposed in most fluid // emitters, but there anyway). // double theRate = getRate(block) * dt * conversion; // get voxel dimensions and sizes (object space) // double size[3]; unsigned int res[3]; fluid.getDimensions( size[0], size[1], size[2] ); fluid.getResolution( res[0], res[1], res[2] ); // voxel sizes double dx = size[0] / res[0]; double dy = size[1] / res[1]; double dz = size[2] / res[2]; // voxel centers double Ox = -size[0]/2; double Oy = -size[1]/2; double Oz = -size[2]/2; // emission will only happen for voxels whose centers lie within // "minDist" and "maxDist" of an emitter position // double minDist = getMinDistance( block ); double maxDist = getMaxDistance( block ); // bump up the min/max distance values so that they // are both > 0, and there is at least about a half // voxel between the min and max values, to prevent aliasing // artifacts caused by emitters missing most voxel centers // MTransformationMatrix fluidXform( fluidWorldMatrix ); double fluidScale[3]; fluidXform.getScale( fluidScale, MSpace::kWorld ); // compute smallest voxel diagonal length double wsX = fabs(fluidScale[0]*dx); double wsY = fabs(fluidScale[1]*dy); double wsZ = fabs(fluidScale[2]*dz); double wsMin = MIN( MIN( wsX, wsY), wsZ ); double wsMax = MAX( MAX( wsX, wsY), wsZ ); double wsDiag = wsMin * sqrt(3.0); // make sure emission range is bigger than 0.5 voxels if ( maxDist <= minDist || maxDist <= (wsDiag/2.0) ) { if ( minDist < 0 ) minDist = 0; maxDist = minDist + wsDiag/2.0; dropoff = 0; } // Now, it's time to actually emit into the fluid: // // foreach emitter point // foreach voxel // - select some points in the voxel // - compute a dropoff function from the emitter point // - emit an appropriate amount of fluid into the voxel // // Since we've already expanded the min/max distances to cover // the smallest voxel dimension, we should only need 1 sample per // voxel, unless the voxels are highly non-square. We increase the // number of samples in these cases. // // If the "jitter" flag is enabled, we jitter each sample position, // using the rangen() function, which keeps track of independent // random states for each fluid, to make sure that results are // repeatable for multiple simulation runs. // // basic sample count int numSamples = 1; // increase samples if necessary for non-square voxels if(wsMin >.00001) { numSamples = (int)(wsMax/wsMin + .5); if(numSamples > 8) numSamples = 8; if(numSamples < 1) numSamples = 1; } bool jitter = fluidJitter(block); if( !jitter ) { // I don't have a good uniform sample generator for an // arbitrary number of samples. It would be a good idea to use // one here. For now, just use 1 sample for the non-jittered case. // numSamples = 1; } for( unsigned int p = 0; p < emitterPositions.length(); p++ ) { MPoint emitterWorldPos = emitterPositions[p]; // loop through all voxels, looking for ones that lie at least // partially within the dropoff field around this emitter point // for( unsigned int i = 0; i < res[0]; i++ ) { double x = Ox + i*dx; for( unsigned int j = 0; j < res[1]; j++ ) { double y = Oy + j*dy; for( unsigned int k = 0; k < res[2]; k++ ) { double z = Oz + k*dz; int si; for( si = 0; si < numSamples; si++ ) { // compute sample point (fluid object space) // double rx, ry, rz; if( jitter ) { rx = x + randgen()*dx; ry = y + randgen()*dy; rz = z + randgen()*dz; } else { rx = x + 0.5*dx; ry = y + 0.5*dy; rz = z + 0.5*dz; } // compute distance from sample to emitter point // MPoint point( rx, ry, rz ); point *= fluidWorldMatrix; MVector diff = point - emitterWorldPos; double distSquared = diff * diff; double dist = diff.length(); // discard if outside min/max range // if( (dist < minDist) || (dist > maxDist) ) { continue; } // drop off the emission rate according to the falloff // parameter, and divide to accound for multiple samples // in the voxel // double distDrop = dropoff * distSquared; double newVal = theRate * exp( -distDrop ) / (double)numSamples; // emit density/heat/fuel/color into the current voxel // if( newVal != 0 ) { fluid.emitIntoArrays( (float) newVal, i, j, k, (float)densityEmit, (float)heatEmit, (float)fuelEmit, doEmitColor, emitColor ); } float *fArray = fluid.falloff(); if( fArray != NULL ) { MPoint midPoint( x+0.5*dx, y+0.5*dy, z+0.5*dz ); midPoint.x *= 0.2; midPoint.y *= 0.2; midPoint.z *= 0.2; float fdist = (float) sqrt( midPoint.x*midPoint.x + midPoint.y*midPoint.y + midPoint.z*midPoint.z ); fdist /= sqrtf(3.0f); fArray[fluid.index(i,j,k)] = 1.0f-fdist; } } } } } } }
// TODO: had synchronized in definition float_t FuzzyTermEnum::similarity(const TCHAR* target, const size_t m) { const size_t n = textLen; // TODO: remove after replacing n with textLen if (n == 0) { //we don't have anything to compare. That means if we just add //the letters for m we get the new word return prefixLength == 0 ? 0.0f : 1.0f - ((float_t) m / prefixLength); } if (m == 0) { return prefixLength == 0 ? 0.0f : 1.0f - ((float_t) n / prefixLength); } const uint32_t maxDistance = getMaxDistance(m); if ( maxDistance < (uint32_t)(abs((int32_t)(m-n))) ) { //just adding the characters of m to n or vice-versa results in //too many edits //for example "pre" length is 3 and "prefixes" length is 8. We can see that //given this optimal circumstance, the edit distance cannot be less than 5. //which is 8-3 or more precisesly Math.abs(3-8). //if our maximum edit distance is 4, then we can discard this word //without looking at it. return 0.0f; } //let's make sure we have enough room in our array to do the distance calculations. //Check if the array must be reallocated because it is too small or does not exist size_t dWidth = n+1; size_t dHeight = m+1; if (d == NULL){ dLen = dWidth*dHeight; d = (int32_t*)(malloc(sizeof(int32_t)*dLen)); } else if (dLen < dWidth*dHeight) { dLen = dWidth*dHeight; d = (int32_t*)(realloc(d, sizeof(int32_t)*dLen)); } memset(d,0,dLen); size_t i; // iterates through the source string size_t j; // iterates through the target string // init matrix d for (i = 0; i <= n; i++){ d[i + (0*dWidth)] = i; } for (j = 0; j <= m; j++){ d[0 + (j*dWidth)] = j; } int32_t __t; //temporary variable for min3 // start computing edit distance TCHAR s_i; // ith character of s for (i = 1; i <= n; i++) { size_t bestPossibleEditDistance = m; s_i = text[i - 1]; for (j = 1; j <= m; j++) { if (s_i != target[j-1]) { min3(d[i-1 + (j*dWidth)], d[i + ((j-1)*dWidth)], d[i-1 + ((j-1)*dWidth)]); d[i + (j*dWidth)] = __t+1; } else { min3(d[i-1 + (j*dWidth)]+1, d[i + ((j-1)*dWidth)]+1, d[i-1 + ((j-1)*dWidth)]); d[i + (j*dWidth)] = __t; } bestPossibleEditDistance = cl_min(bestPossibleEditDistance, d[i + (j*dWidth)]); } //After calculating row i, the best possible edit distance //can be found by finding the smallest value in a given column. //If the bestPossibleEditDistance is greater than the max distance, abort. if (i > maxDistance && bestPossibleEditDistance > maxDistance) { //equal is okay, but not greater //the closest the target can be to the text is just too far away. //this target is leaving the party early. return 0.0f; } } // this will return less than 0.0 when the edit distance is // greater than the number of characters in the shorter word. // but this was the formula that was previously used in FuzzyTermEnum, // so it has not been changed (even though minimumSimilarity must be // greater than 0.0) return 1.0f - ((float_t)d[n + m*dWidth] / (float_t) (prefixLength + cl_min(n, m))); }
int OnNewvision(IplImage* currImageBefore, IplImage* maskImage) { //int pAPosition[6][2]={0};//pointArrayPosition //pAPosition[0][0]=0; pAPosition[0][1]=6; //pAPosition[1][0]=6; pAPosition[1][1]=0; //pAPosition[2][0]=12;pAPosition[2][1]=6; //pAPosition[3][0]=0; pAPosition[3][1]=9; //pAPosition[4][0]=6; pAPosition[4][1]=12; //pAPosition[5][0]=12;pAPosition[5][1]=9; //ListPoint pointSet1; //pointSet1.Item = (ArrayPoint*)MallocArrayPoint(); //for (int dIndex = 0; dIndex <3; dIndex++) //{//cvPoint(wIndex, hIndex) // pointSet1.Item->push_back(cvPoint(pAPosition[dIndex][0], pAPosition[dIndex][1])); //} // //cvCircleObj outCircle1; //if(pointSet1.Item->size() == 0) // return; //FitCircleObj(pointSet1, &outCircle1); //ListPoint pointSet2; //pointSet2.Item = (ArrayPoint*)MallocArrayPoint(); //for (int dIndex = 3; dIndex <6; dIndex++) //{//cvPoint(wIndex, hIndex) // pointSet2.Item->push_back(cvPoint(pAPosition[dIndex][0], pAPosition[dIndex][1])); //} //cvCircleObj outCircle2; //if(pointSet2.Item->size() == 0) // return; //FitCircleObj(pointSet2, &outCircle2); //IplImage* currImage1 = cvCreateImage(cvSize(2000, 3000), IPL_DEPTH_8U, 1); //memset(currImage1->imageData, 0, currImage1->height*currImage1->widthStep*sizeof(unsigned char)); //int bwPosition = 0; //for (int hIndex = 0; hIndex < currImage1->width; hIndex++) //{ // int y1 = 0, y2 = 0; // y1 = sqrt( outCircle1.Radius * outCircle1.Radius - hIndex * hIndex); // y2 = sqrt( outCircle2.Radius * outCircle2.Radius - hIndex * hIndex); // for (int wIndex = 0; wIndex < currImage1->height; wIndex++) // { // bwPosition = hIndex*currImage1->widthStep + wIndex; // if( wIndex < y1) // currImage1->imageData[bwPosition] = 0; // else if (wIndex > y1 && wIndex < y2) // currImage1->imageData[bwPosition] = 255; // else // currImage1->imageData[bwPosition] = 0; // } //} //cvShowImage("currImage1",currImage1); //cvWaitKey(0); //cvReleaseImage(&currImage1); //return; int hIndex = 0, wIndex = 0, ImagePosition = 0, TempPosition = 0, colorValue = 0; bool leakLight = false; int LeakLightNum = 5; //IplImage* currImageBefore = cvLoadImage("00.bmp", CV_LOAD_IMAGE_GRAYSCALE); if (currImageBefore == NULL) return 1; if (maskImage == NULL) { return 2; } IplImage* currImage = cvCreateImage(cvSize(currImageBefore->width, currImageBefore->height), IPL_DEPTH_8U, 1); memset(currImage->imageData, 0, currImage->height*currImage->widthStep*sizeof(unsigned char)); //使用Mask cvCopy(currImageBefore, currImage, maskImage); //cvShowImage("currImage",currImage); //cvWaitKey(0); IplImage* EdgeImage = cvCreateImage(cvSize(currImageBefore->width, currImageBefore->height), IPL_DEPTH_8U, 1); memset(EdgeImage->imageData, 0, EdgeImage->height*EdgeImage->widthStep*sizeof(unsigned char)); cvCanny(currImage, EdgeImage, 50, 180, 3); //cvShowImage("EdgeImage", EdgeImage); //cvWaitKey(0); int edgeTempPosition = 0; for (int hIndex = 1; hIndex < EdgeImage->height - 1; hIndex++) { for (int wIndex = 1; wIndex < EdgeImage->width - 1; wIndex++) { edgeTempPosition = hIndex*EdgeImage->widthStep + wIndex; if (EdgeImage->imageData[edgeTempPosition] == 255) if (maskImage->imageData[edgeTempPosition + 1] == 0 || maskImage->imageData[edgeTempPosition - 1] == 0 || maskImage->imageData[edgeTempPosition + maskImage->widthStep] == 0 || maskImage->imageData[edgeTempPosition - maskImage->widthStep] == 0) EdgeImage->imageData[edgeTempPosition] = 0; } } //cvShowImage("EdgeImage2", EdgeImage); ////cvSaveImage("E:\\wuxi\\EdgeImage.jpg",EdgeImage); //cvWaitKey(0); ListPoint pointSet; ListPoint bestPoint; ListPoint tempPoint; pointSet.Item = (ArrayPoint*)MallocArrayPoint(); bestPoint.Item = (ArrayPoint*)MallocArrayPoint(); tempPoint.Item = (ArrayPoint*)MallocArrayPoint(); ListPoint pointSet13, pointSet23, pointSet33; ListPoint bestPoint13, bestPoint23, bestPoint33; pointSet13.Item = (ArrayPoint*)MallocArrayPoint(); pointSet23.Item = (ArrayPoint*)MallocArrayPoint(); pointSet33.Item = (ArrayPoint*)MallocArrayPoint(); bestPoint13.Item = (ArrayPoint*)MallocArrayPoint(); bestPoint23.Item = (ArrayPoint*)MallocArrayPoint(); bestPoint33.Item = (ArrayPoint*)MallocArrayPoint(); IplImage* markImage = cvCreateImage(cvGetSize(currImage), IPL_DEPTH_8U, 1); memset(markImage->imageData, 0, markImage->height*markImage->widthStep*sizeof(unsigned char)); //ArrayPoint* PointArray = (ArrayPoint*)MallocArrayPoint(); ListRect rectList; ListInt intAreaList; rectList.Item = (ArrayRect*)MallocArrayRect(); intAreaList.Item = (ArrayInt *)MallocArrayInt(); ExtractAllEdgePointNumForItem(EdgeImage, markImage, cvRect(0, 0, currImageBefore->width, currImageBefore->height), 255, &pointSet); //未搜寻到边缘点,可能是已经边缘效果不好或者是无料 if (pointSet.Item->size() == 0 || pointSet.Item->size() < 10) { cvReleaseImage(&currImageBefore); //cvReleaseImage(&maskImage); cvReleaseImage(&markImage); cvReleaseImage(&currImage); cvReleaseImage(&EdgeImage); return 3; } CvPoint PartTempPoint; for (int dIndex = 0; dIndex < pointSet.Item->size() / 3; dIndex++) { PartTempPoint = (*pointSet.Item)[dIndex]; AddArrayPoint(pointSet13.Item, PartTempPoint); } cvCircleObj TempCircle; memset(markImage->imageData, 0, markImage->height*markImage->widthStep*sizeof(unsigned char)); //之前使用方法为全部进行ransac滤除,之后为缩短时间修改为1/3、1/3、1/3进行滤除 //RansacCirclePoint(pointSet, &bestPoint, &tempPoint); //if(bestPoint.Item->size() == 0) //{ // cvReleaseImage(&currImageBefore); // cvReleaseImage(&maskImage); // cvReleaseImage(&markImage); // cvReleaseImage(&currImage); // cvReleaseImage(&EdgeImage); // return; //} //SortPointsListByXValue(&bestPoint); RansacCirclePoint(pointSet13, &bestPoint13, &tempPoint); if (bestPoint13.Item->size() == 0) { cvReleaseImage(&currImageBefore); //cvReleaseImage(&maskImage); cvReleaseImage(&markImage); cvReleaseImage(&currImage); cvReleaseImage(&EdgeImage); return 4; } cvCircleObj outCircle; cvCircleObj outCircle13, outCircle23, outCircle33; //ListPoint bestPoint13, bestPoint23, bestPoint33; //bestPoint13.Item = (ArrayPoint*)MallocArrayPoint(); //bestPoint23.Item = (ArrayPoint*)MallocArrayPoint(); //bestPoint33.Item = (ArrayPoint*)MallocArrayPoint(); //for (int dIndex = 0; dIndex< bestPoint.Item->size()/3; dIndex++) //{ // AddArrayPoint(bestPoint13.Item, (*bestPoint.Item)[dIndex]); //} FitCircleObj(bestPoint13, &outCircle13); if (outCircle13.CirclePoint.x < 0 || outCircle13.CirclePoint.y >0) { for (int dIndex = pointSet.Item->size() / 3; dIndex < 2 * pointSet.Item->size() / 3; dIndex++) { PartTempPoint = (*pointSet.Item)[dIndex]; AddArrayPoint(pointSet23.Item, PartTempPoint); } RansacCirclePoint(pointSet23, &bestPoint23, &tempPoint); if (bestPoint23.Item->size() == 0) { cvReleaseImage(&currImageBefore); //cvReleaseImage(&maskImage); cvReleaseImage(&markImage); cvReleaseImage(&currImage); cvReleaseImage(&EdgeImage); return 5; } FitCircleObj(bestPoint23, &outCircle23); if (outCircle23.CirclePoint.x < 0 || outCircle23.CirclePoint.y >0) { for (int dIndex = 2 * pointSet.Item->size() / 3; dIndex < pointSet.Item->size(); dIndex++) { PartTempPoint = (*pointSet.Item)[dIndex]; AddArrayPoint(pointSet33.Item, PartTempPoint); } RansacCirclePoint(pointSet33, &bestPoint33, &tempPoint); if (bestPoint33.Item->size() == 0) { cvReleaseImage(&currImageBefore); //cvReleaseImage(&maskImage); cvReleaseImage(&markImage); cvReleaseImage(&currImage); cvReleaseImage(&EdgeImage); return 6; } FitCircleObj(bestPoint33, &outCircle33); if (outCircle33.CirclePoint.x < 0 || outCircle33.CirclePoint.y >0) { outCircle.CirclePoint.x = 0; outCircle.CirclePoint.y = 1; outCircle.Radius = 1; } else outCircle = outCircle33;; } else outCircle = outCircle23; } else outCircle = outCircle13; //FitCircleObj(bestPoint, &outCircle); if (outCircle.CirclePoint.y == 1 && outCircle.Radius == 1) { cvReleaseImage(&currImageBefore); //cvReleaseImage(&maskImage); cvReleaseImage(&markImage); cvReleaseImage(&currImage); cvReleaseImage(&EdgeImage); return 7; } ListPoint pointOutCircleSet; pointOutCircleSet.Item = (ArrayPoint*)MallocArrayPoint(); int radiusAdd = 0; int radiusMove = 35; for (int dIndex = 0; dIndex < VL_MAX(bestPoint.Item->size(), 0); dIndex++) { CvPoint TempPoint; TempPoint.x = ((*bestPoint.Item)[dIndex]).x; TempPoint.y = ((*bestPoint.Item)[dIndex]).y + radiusMove; AddArrayPoint(pointOutCircleSet.Item, TempPoint); } ListPoint pointMoreCircleSet; pointMoreCircleSet.Item = (ArrayPoint*)MallocArrayPoint(); for (int wIndex = 0; wIndex < currImageBefore->width; wIndex++) { CvPoint TempPoint; CvPoint TempOutPoint; float x = 0, y = 0; x = wIndex - outCircle.CirclePoint.x; //y = dIndex - outCircle.CirclePoint.y; y = sqrt((outCircle.Radius + radiusMove) * (outCircle.Radius + radiusMove) - x * x); TempPoint.x = wIndex; if (outCircle.CirclePoint.y < 0) y = VL_MAX(0, outCircle.CirclePoint.y + y); else y = VL_MAX(0, outCircle.CirclePoint.y - y); TempPoint.y = y; if (TempPoint.x >= 0 && TempPoint.y >= 0) AddArrayPoint(pointMoreCircleSet.Item, TempPoint); } SortPointsListByXValue(&pointMoreCircleSet); int maskCircleTemp = 0; for (int wIndex = 0; wIndex < markImage->width; wIndex++) { for (int hIndex = 0; hIndex < markImage->height; hIndex++) { maskCircleTemp = hIndex*markImage->widthStep + wIndex; if (hIndex <= ((*pointMoreCircleSet.Item)[wIndex]).y) { markImage->imageData[maskCircleTemp] = 255; } } } int a[4] = { 0 }; //currImageBefore = cvLoadImage("E:\\wuxi\\leak\\1532.bmp", CV_LOAD_IMAGE_GRAYSCALE); getMaxDistance(currImageBefore, &pointMoreCircleSet, a); int subPotion = 0; for (int hIndex = 0; hIndex < markImage->height; hIndex++) { for (int wIndex = 0; wIndex < markImage->width; wIndex++) { subPotion = hIndex*markImage->widthStep + wIndex; //currImageBefore->imageData[subPotion] -= maskCircle->imageData[subPotion]; //if (maskCircle->imageData[subPotion] == 255) // currImageBefore->imageData[subPotion] = 0; if (currImageBefore->imageData[subPotion] - markImage->imageData[subPotion] <= 0) currImageBefore->imageData[subPotion] = 0; if (currImageBefore->imageData[subPotion] - markImage->imageData[subPotion] >= 255) currImageBefore->imageData[subPotion] = 255; } } cvThreshold(currImageBefore, markImage, 110, 255, CV_THRESH_BINARY); //cvShowImage("currbf", currImageBefore); //cvWaitKey(0); CvPoint LineCenter; CvPoint LineCenter2; LineCenter2.x = (int)outCircle.CirclePoint.x; LineCenter2.y = (int)outCircle.CirclePoint.y; //LineCenter.x = (a[1]+a[0]/2); LineCenter.x = a[1] + a[0] / 2; LineCenter.y = a[3]; CvSize imgSize = cvSize(currImageBefore->width, currImageBefore->height); CvRect Zone; Zone.x = 0; Zone.y = 0; Zone.width = 0; Zone.height = 0; int checkLightValue = 55; bool Zone0 = false, Zone1 = false, Zone2 = false, Zone3 = false, Zone4 = false; //没有豁口区域 if (a[0] == 0) { if (getMinYPositon(&pointMoreCircleSet, 0, currImage->width, &Zone, a, imgSize, 0)) { if (getMinYPositon(&pointMoreCircleSet, 0, currImageBefore->width, &Zone, a, imgSize, 0)) Zone0 = CheckZoneLeak(currImageBefore, Zone, LeakLightNum, checkLightValue); //IplImage* ZoneImg = cvCreateImage(cvSize(Zone.width, Zone.height), IPL_DEPTH_8U, 1); //memset(ZoneImg->imageData, 0, ZoneImg->height*ZoneImg->widthStep*sizeof(unsigned char)); //IplImage* ZoneImg2 = cvCreateImage(cvSize(Zone.width, Zone.height), IPL_DEPTH_8U, 1); //memset(ZoneImg2->imageData, 0, ZoneImg2->height*ZoneImg2->widthStep*sizeof(unsigned char)); //cvSetImageROI(currImageBefore,Zone); //cvCopy(currImageBefore,ZoneImg); //cvResetImageROI(currImageBefore); //cvThreshold(ZoneImg, ZoneImg2, 110, 255, CV_THRESH_BINARY); //int leakNum = 0; //int bwPosition = 0; //for (int hIndex = 0; hIndex < ZoneImg2->height; hIndex++) //{ // for (int wIndex = 0; wIndex < ZoneImg2->width; wIndex++) // { // bwPosition = hIndex*ZoneImg2->widthStep + wIndex; // if( ZoneImg2->imageData[bwPosition] == 255) // leakNum++; // } //} //if (leakNum > LeakLightNum) //{ // leakLight = true; // //cvShowImage("ZoneImage2", ZoneImg2); // //cvWaitKey(0); //} //cvReleaseImage(&ZoneImg); } //getMinYPositon(ListPoint* line, int firstPosition, int lastPosition, CvRect* zone, int* a, int direction) } else//有豁口区域 { //getMinYPositon if (a[1] > currImageBefore->width / 2) { if (getMinYPositon(&pointMoreCircleSet, a[2], currImageBefore->width, &Zone, a, imgSize, 4)) Zone4 = CheckZoneLeak(currImageBefore, Zone, LeakLightNum, checkLightValue); if (getMinYPositon(&pointMoreCircleSet, 0, a[1], &Zone, a, imgSize, 3)) Zone3 = CheckZoneLeak(currImageBefore, Zone, LeakLightNum, checkLightValue); } if (a[1] <= currImageBefore->width / 2) { if (getMinYPositon(&pointMoreCircleSet, 0, a[1], &Zone, a, imgSize, 1)) Zone1 = CheckZoneLeak(currImageBefore, Zone, LeakLightNum, checkLightValue); if (getMinYPositon(&pointMoreCircleSet, a[2], currImageBefore->width, &Zone, a, imgSize, 2)) Zone2 = CheckZoneLeak(currImageBefore, Zone, LeakLightNum, checkLightValue); } } cvReleaseImage(&currImageBefore); //cvReleaseImage(&maskImage); cvReleaseImage(&markImage); cvReleaseImage(&currImage); cvReleaseImage(&EdgeImage); bool lastResult = false; if (Zone0 || Zone1 || Zone2 || Zone3 || Zone4) { lastResult = true; return -1; } lastResult = false; return 0; }