void GrabCutSegmentor::Run()
{
	cout<<"====="<<m_Name<<" Runing..."<<endl;

	namedWindow(m_WinName);
	setMouseCallback(m_WinName, onMouse, this);
	showImage();

	cout << "\nThe Grabcut Segmentation\n"
        "\nSelect a rectangular area around the object you want to segment\n" <<
        "\tESC - Finished\n"
        "\tr - restore the original image\n"
        "\ts - do segmentation\n"
        "\tleft mouse button - set rectangle\n"
        "\tCTRL+left mouse button - set GC_BGD pixels\n"
        "\tSHIFT+left mouse button - set CG_FGD pixels\n"
        "\tCTRL+right mouse button - set GC_PR_BGD pixels\n"
        "\tSHIFT+right mouse button - set CG_PR_FGD pixels\n" << endl;

	for(;;)
    {
        int c = waitKey(0);
        switch( (char) c )
        {
        case '\x1b':
            cout << "Exiting ..." << endl;
            goto exit;
        case 'r':
            cout << endl;
            reset();
            showImage();
            break;
        case 's':
			int iter = iterCount;
            //cout << "<" << iterCount << "... ";
            int newIterCount = nextIter();
            if( newIterCount > iter )
            {
                showImage();
                cout << "Finished!" << endl;
            }
            else
                cout << "rect must be determined!" << endl;
            break;
        }
    }

exit:
	m_Mask = m_Mask & 1;
	m_Mask.convertTo(m_Result, CV_32SC1);

	destroyWindow( m_WinName );	

	Segmentor::Run();
}
Beispiel #2
0
// ------------------------------------------------------------ Print operands stack
void printAnds( const Stack Ands )
{
  Iter si = newIter( Ands );

  printf( "\nStack has %d items: bottom<[ ", sizeStack( Ands ) );
  while (hasNextIter( si )) {
    printOperand( nextIter( si ) );  
  }
  printf( "  ]>top\n" );

  freeIter( si );
}
Beispiel #3
0
BOOL CGetStoreFoldersIter::HandleHierarchyItem( ULONG oType, ULONG cb, LPENTRYID pEntry)
{
  if (oType == MAPI_FOLDER) {
    LPMAPIFOLDER pFolder;
    if (m_pApi->OpenEntry( cb, pEntry, (LPUNKNOWN *) &pFolder)) {
      LPSPropValue    pVal;
      nsString      name;

      pVal = m_pApi->GetMapiProperty( pFolder, PR_CONTAINER_CLASS);
      if (pVal)
        m_pApi->GetStringFromProp( pVal, name);
      else
        name.Truncate();

      if ((name.IsEmpty() && m_isMail) || (!ExcludeFolderClass(name.get()))) {
        pVal = m_pApi->GetMapiProperty( pFolder, PR_DISPLAY_NAME);
        m_pApi->GetStringFromProp( pVal, name);
        CMapiFolder  *pNewFolder = new CMapiFolder(name.get(), cb, pEntry, m_depth);
        m_pList->AddItem( pNewFolder);

        pVal = m_pApi->GetMapiProperty( pFolder, PR_FOLDER_TYPE);
        MAPI_TRACE2( "Type: %d, name: %s\n", m_pApi->GetLongFromProp( pVal), (const char *)name);
        // m_pApi->ListProperties( pFolder);

        CGetStoreFoldersIter  nextIter( m_pApi, *m_pList, m_depth + 1, m_isMail);
        m_pApi->IterateHierarchy( &nextIter, pFolder);
      }
      pFolder->Release();
    }
    else {
      MAPI_TRACE0( "GetStoreFolders - HandleHierarchyItem: Error opening folder entry.\n");
      return( FALSE);
    }
  }
  else
    MAPI_TRACE1( "GetStoreFolders - HandleHierarchyItem: Unhandled ObjectType: %ld\n", oType);
  return( TRUE);
}