//=================================================================================
void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
{
-
+ MESSAGE("EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()")
// TODO supprimer les lignes qui ne servent à rien le cas échéant
SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
TopoDS_Shape aShape;
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ MESSAGE("EntityGUI_FeatureDetectorDlg::SelectionIntoArgument() # REPERE 1")
QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName );
else
return ;
- std::string theImgFileName = myAISShape->TextureFile();
- if ( theImgFileName == "" )
- return ;
+ MESSAGE("EntityGUI_FeatureDetectorDlg::SelectionIntoArgument() # REPERE 2")
+ //std::string theImgFileName = myAISShape->TextureFile();
+ Image_PixMap anImage = myAISShape->Image_PixMap();
+// MESSAGE("theImgFileName = "<<theImgFileName)
+// if ( theImgFileName == "" )
+// return ;
// Setting the image caracteristics
- myDetector->SetPath( theImgFileName );
+// MESSAGE("theImgFileName = "<<theImgFileName)
+// myDetector->SetPath( theImgFileName );
+ myDetector->SetImage( anImage );
height = myDetector->GetImgHeight();
width = myDetector->GetImgWidth();
pictureLeft = -0.5 * width; // X coordinate of the top left corner of the background image in the view
{
myEndPnt = theEndPnt;
MESSAGE("myEndPnt = ("<<theEndPnt.X()<<", "<<theEndPnt.Y()<<")")
+ bool test_1 = myDetector->GetImgHeight() > 0;
+ MESSAGE("REPERE 0 : setSelectionRect() = "<<setSelectionRect()<<"myDetector->GetImgHeight()"<<myDetector->GetImgHeight())
if (setSelectionRect() && myDetector->GetImgHeight() > 0)
+ {
+ MESSAGE("REPERE 1")
showImageSample();
+ }
}
//=================================================================================
// Cropp the image to the selection rectangle given by the user
myDetector->SetROI( myRect );
std::string samplePicturePath = myDetector->CroppImage();
+ MESSAGE("samplePicturePath = "<<samplePicturePath)
// Display the result
QPixmap pixmap(QString(samplePicturePath.c_str()));
// Qt
#include <QRect>
+#include <QPixmap>
#ifdef WIN32
#if defined GEOM_SHAPEREC_EXPORTS || defined GEOMShapeRec_EXPORTS
#define GEOM_SHAPEREC_EXPORT
#endif
+
+// If inImage exists for the lifetime of the resulting cv::Mat, pass false to inCloneImageData to share inImage's
+// data with the cv::Mat directly
+// NOTE: Format_RGB888 is an exception since we need to use a local QImage and thus must clone the data regardless
+inline cv::Mat QImageToCvMat( const QImage &inImage, bool inCloneImageData = true )
+{
+ switch ( inImage.format() )
+ {
+ // 8-bit, 4 channel
+ case QImage::Format_RGB32:
+ {
+ cv::Mat mat( inImage.height(), inImage.width(), CV_8UC4, const_cast<uchar*>(inImage.bits()), inImage.bytesPerLine() );
+
+ return (inCloneImageData ? mat.clone() : mat);
+ }
+
+ // 8-bit, 3 channel
+ case QImage::Format_RGB888:
+ {
+ if ( !inCloneImageData )
+ qWarning() << "ASM::QImageToCvMat() - Conversion requires cloning since we use a temporary QImage";
+
+ QImage swapped = inImage.rgbSwapped();
+
+ return cv::Mat( swapped.height(), swapped.width(), CV_8UC3, const_cast<uchar*>(swapped.bits()), swapped.bytesPerLine() ).clone();
+ }
+
+ // 8-bit, 1 channel
+ case QImage::Format_Indexed8:
+ {
+ cv::Mat mat( inImage.height(), inImage.width(), CV_8UC1, const_cast<uchar*>(inImage.bits()), inImage.bytesPerLine() );
+
+ return (inCloneImageData ? mat.clone() : mat);
+ }
+
+ default:
+ qWarning() << "ASM::QImageToCvMat() - QImage format not handled in switch:" << inImage.format();
+ break;
+ }
+
+ return cv::Mat();
+}
+
+// If inPixmap exists for the lifetime of the resulting cv::Mat, pass false to inCloneImageData to share inPixmap's data
+// with the cv::Mat directly
+// NOTE: Format_RGB888 is an exception since we need to use a local QImage and thus must clone the data regardless
+inline cv::Mat QPixmapToCvMat( const QPixmap &inPixmap, bool inCloneImageData = true )
+{
+ return QImageToCvMat( inPixmap.toImage(), inCloneImageData );
+}
+
class GEOM_SHAPEREC_EXPORT ShapeRec_Parameters
{
public: