open .tif images



  • I am working on raster images I have configured OpenCV in Qt creator now it is working fine when I am working with .png or .jpg images, but when I am trying to open .tif type rasters program crashes, after exploring different forums I came to know about a libtiff library in OpenCV, Now after including header files of that library it shows error that no such file or directory found, I searched for libtiff.dll file in the OpenCV-build folder but no such dll file was found.

    Please help.



  • Hi @navya.dubey

    OpenCV is not a part of Qt.

    On the other hand, I myself have no problems to read tif-files with OpenCV (on WINDOWS). I just need opencv core and imgcodecs and imageproc dlls.

    -Michael.



  • @m-sue could you please share the code to open .tif files in Qt , because I am facing some issues.



  • Hi @navya.dubey

    In Qt itself it is quite simple:

    	QImage qi;
    	if (!qi.load(szFileName)) {
    		//return error
    	}
    

    But you will need to distribute the tiff image plugin with your program (and make it available to your self while testing): ...\plugins\imageformats\qtiff.dll

    CAVEAT: Qt cannot read in 16-bit per color-channel images. That's why I use OpenCV at the moment.

    -Michael.



  • @m.sue dear sir,
    don't you think I need to do some external configuration to work with .tif files? Because I am getting the following errors. Now these errors can occur due to the misunderstanding about how to use geotiff function
    0_1502876884275_Screenshot (9).png


  • Moderators

    @navya.dubey Just change scanline to unsigned char* or do an explicit type cast to get rid of that error message.
    Regarding the crash: you should tell what exactly is happening (SIGSEGV?)and maybe post a stack trace.
    Ans as @m-sue already said your question is not related to Qt, it could be better to ask in an OpenCV forum.



  • @jsulm OK I'll ask my question on OpenCV forum, but could you please tell me that is there any inbuilt function in Qt to load .tiff files?


  • Moderators

    @navya.dubey Actually a standard Qt set-up should support tiff images out of the box. You should have qtiff.dll plugin in gcc_64/plugins/imageformats. If you have one and it is not working (QImage/QPixmap) then maybe the libtiff is missing. You can check that setting QT_DEBUG_PLUGINS variable before starting your app. Did you try to load your images using QImage?



  • @navya.dubey The same as every other image format. Please refer to QImage, QPixmap and QPicture docs.

    As for supported image format default ones are listed in QImageReader docs, TIFF is being read by 3rd party plugin - detailed info here.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.