first try for fix (doesn't compile)

This commit is contained in:
Florian BRUNET 2015-04-23 16:46:20 +02:00
parent 38f47f419d
commit 9e1826c51b
3 changed files with 80 additions and 5 deletions

View File

@ -396,7 +396,7 @@ void EntityGUI_FeatureDetectorDlg::Init()
//=================================================================================
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;
@ -428,6 +428,7 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
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 );
@ -445,12 +446,17 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
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
@ -677,8 +683,13 @@ void EntityGUI_FeatureDetectorDlg::setEndPnt(const gp_Pnt& theEndPnt)
{
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();
}
}
//=================================================================================
@ -710,6 +721,7 @@ void EntityGUI_FeatureDetectorDlg::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()));

View File

@ -64,6 +64,17 @@ void ShapeRec_FeatureDetector::SetPath( const std::string& thePath )
}
}
/*!
Sets the the image to be processed
\param theImage - QPixMap input image
*/
void ShapeRec_FeatureDetector::SetImage( const QPixmap& input_img )
{
cv::Mat image = QPixmapToCvMat( input_img, false );
}
/*!
Computes the corners of the image located at imagePath
*/

View File

@ -31,6 +31,7 @@
// Qt
#include <QRect>
#include <QPixmap>
#ifdef WIN32
#if defined GEOM_SHAPEREC_EXPORTS || defined GEOMShapeRec_EXPORTS
@ -42,6 +43,57 @@
#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: