tproduit / pic2map

QGIS plugin for camera orientation and interaction between a picture and the map (monoplotting).
22 stars 5 forks source link

Save raster problem #20

Closed diomitri closed 4 years ago

diomitri commented 4 years ago

I have installed Pic2Map 3.3 in QGIS 3.12.2 after installing OpenGL, OpenGL accelerate, piexif python modules via OSGeo4W cmd. However, 3D-view function doesn't seems to work properly, and most important, I cannot save/export the orthorectified image: After designing the purple box of area of interest and pressing Save Raster, nothing happens, or no error message is shown. What might be the problem? (OS: Windows 10 64-bit)

frpin33 commented 4 years ago

Hello Diomitri,

Is it your first time using Pic2Map or did you use an older version before? What's the issue with 3D-view? This function wasn't change in the newer version and you are the first one to manifest an issue with it. In the 3D-View you can move around with the mouse and change the world position of your current ground control point. Which of those 2 features doesn't seems to work properly? It might also be the Raster Layer that you are using, you can try using the raster layer in the dataTest folder (Pic2Map/dataTest/AletschGlacierDEM.tiff)

For the export, a known bug is that the progress bar stop at 99% when you click on the Orthorectification button. Most of the time you can just relauch it and it should work. But I think that's not your issue. First thing first, the calculation time is very very long, to see if it's running put your mouse over the orthorectification window. On window you should see the blue circle meaning it's waiting/working, the window should say not responding. After a while, you should have a result.

I've look at the changes in the last update and I found why it's so slow. If you go to the file ortho.py at the line 499, 500, 501 and 508 and change method='cubic' to method='nearest'. It should up the speed a bit. I made this change without realizing the effect it had so this is on me. It's still a bit slow but it should be much faster.

If you need help on how to change the python file don't hesitate to ask.

diomitri commented 4 years ago

Hallo, yes indeed it's my first time using Pic2Map. 3D-view is not a matter to me, since I already have GCP points and image coordinates for my airphotos (collected from orthophotos), using the Georeferencer tool. I also changed the method to 'nearest' as you suugested, but it doesn't seem to be the problem, since the original image becomes actually orthorectified either way. My problem is that I cannot export/save the orthorectified image, after pressing button "Save raster". Thanks for your interest. image

frpin33 commented 4 years ago

Like I said in my last comment, when you click the save raster button, the process should be starting. You can see if it's running with the mouse and with the window (Mainwindow) not responding. Is it the case for you or it doesn't even happen? After a while the save file window should appear. Do you have any warning or error occuring meanwhile? You can increase the pixel size to accelerate the program. Without any indication from QGIS (python error, warning or crash) it's hard for me to find the problem.

image

diomitri commented 4 years ago

Unfortunately, there's no indication from QGIS. Mainwindow does not seem to crash/not respond, even through Work Manager of Windows. However, Save file dialog window won't open even after waiting for some minutes. I also reduced DEM to size <1MB and image type to Integer16, like the one in the datatest folder. Finally, I actually tried the test data with no result... Should it be a python version problem (python37)? Downgrading to 3.2 should work?

apiszcz commented 4 years ago

I noted a few issues a while ago, here they are again. These issues may already be fixed.

------------------------
ui_monoplotter.py
line 65: self.spinBox.setMaximum (4096)

------------
ortho.py
FROM
            grid_z0 = np.uint8(interpolate.griddata(imPoints.T, np.squeeze(imLine[0,:]), (grid_x,grid_y), method='nearest'))
            grid_z1 = np.uint8(interpolate.griddata(imPoints.T, np.squeeze(imLine[1,:]), (grid_x,grid_y), method='nearest'))
            grid_z2 = np.uint8(interpolate.griddata(imPoints.T, np.squeeze(imLine[2,:]), (grid_x,grid_y), method='nearest'))

TO
            grid_z0 = np.uint8(interpolate.griddata(imPoints.T, np.squeeze(imLine[0,:]), (grid_x,grid_y), method='cubic'))
            grid_z1 = np.uint8(interpolate.griddata(imPoints.T, np.squeeze(imLine[1,:]), (grid_x,grid_y), method='cubic'))
            grid_z2 = np.uint8(interpolate.griddata(imPoints.T, np.squeeze(imLine[2,:]), (grid_x,grid_y), method='cubic'))

Line 44 ADD
from skimage.transform import resize as skresize

FROM: ~426,440, 445
       self.image = misc.imresize(self.image, (newHeight, newWidth))
        imX = misc.imresize(imX,(newHeight, newWidth), interp = 'bicubic', mode = 'F')
        imY = misc.imresize(imY,(newHeight, newWidth), interp = 'bicubic', mode = 'F')
TO
        self.image = Image.fromarray(self.image).resize((newHeight, newWidth),resample=Image.BICUBIC)
        imX = Image.fromarray(imX).resize((newHeight, newWidth), resample=Image.BICUBIC)
        imY = Image.fromarray(imY).resize((newHeight, newWidth), resample=Image.BICUBIC)

DELETE THIS
       self.image = misc.imresize(self.image, (newHeight, newWidth))
        imX = misc.imresize(imX,(newHeight, newWidth), interp = 'bicubic', mode = 'F')
        imY = misc.imresize(imY,(newHeight, newWidth), interp = 'bicubic', mode = 'F')
TO
       self.image = skresize(self.image, (newHeight, newWidth))
        imX = skresize(imX,(newHeight, newWidth), interp = 'bicubic', mode = 'F')
        imY = skimresize(imY,(newHeight, newWidth), interp = 'bicubic', mode = 'F')

getGCPMainWindow.py (mrv)
around line 758
        if factor > 1  and self.countZoom < 25 and zoomOnGCP == False :
            self.countZoom += 1
            self.ui.graphicsView.scale(ZoomInFactor, ZoomInFactor)
            self.iconSet.SM = self.iconSet.SM * ZoomOutFactor      ###  NEW
            self.iconSet.WM = self.iconSet.WM * ZoomOutFactor  ###  NEW

        elif factor < 1 and self.countZoom > -2 and zoomOnGCP == False :
            self.countZoom -= 1
            self.ui.graphicsView.scale(ZoomOutFactor, ZoomOutFactor)
            self.iconSet.SM = self.iconSet.SM * ZoomInFactor     ###  NEW
            self.iconSet.WM = self.iconSet.WM * ZoomInFactor ###  NEW

        # self.iconSet.SM = int((-2.8148*self.countZoom) + 74.37)     #COMMENT OUT
        # self.iconSet.WM = int((-0.6666*self.countZoom) + 18.66)   #COMMENT OUT
frpin33 commented 4 years ago

You can try downgrading, I didn't program this part of the extension so it was untouch on the version 3. You can also try in the version for QGIS 2 to see if you get the same result. I'm currently on 3.12 and it does work so I don't think it's the python version.

frpin33 commented 4 years ago

@apiszcz Yes those issues were fix in the newest version, thanks for the notes

diomitri commented 4 years ago

Issue solved, finally exporting to ortho.tif needs more time. I also changed original image format from .tiff to .jpg.