内存使用优化
This commit is contained in:
@@ -161,6 +161,7 @@ func (r *Registrator) CalcDownPhaseCorrelation() error {
|
||||
|
||||
// 将PAN将采样作为轮廓匹配基准图像
|
||||
downsampledPanImage := gocv.NewMat()
|
||||
defer downsampledPanImage.Close()
|
||||
gocv.Resize(r.PanImage, &downsampledPanImage,
|
||||
image.Point{X: r.MssWidth, Y: r.MssHeight}, 0, 0, gocv.InterpolationCubic)
|
||||
log.Println("down sampled PAN images size:", downsampledPanImage.Size())
|
||||
@@ -385,6 +386,9 @@ func (r *Registrator) DoCoRegistration() error {
|
||||
gocv.InterpolationCubic,
|
||||
gocv.BorderConstant,
|
||||
color.RGBA{0, 0, 0, 0})
|
||||
|
||||
mapX.Close()
|
||||
mapY.Close()
|
||||
}
|
||||
|
||||
// 裁掉末尾的的 MSS 480 行 和 PAN 的 480*4 行
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"image"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/airbusgeo/godal"
|
||||
@@ -88,6 +89,7 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
||||
matFiltered := rrc.HFNoiseFilter(mat, float64(mat.Cols())*config.GCONFIG.Radiation.HfRadiusRatio)
|
||||
mat.Close()
|
||||
mat = matFiltered
|
||||
runtime.GC()
|
||||
}
|
||||
|
||||
if config.GCONFIG.Radiation.SceneMomentMatching {
|
||||
@@ -132,6 +134,7 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
||||
matFiltered := rrc.HFNoiseFilter(mat, float64(mat.Cols())*config.GCONFIG.Radiation.HfRadiusRatio/4)
|
||||
mat.Close()
|
||||
mat = matFiltered
|
||||
runtime.GC()
|
||||
}
|
||||
|
||||
if config.GCONFIG.Radiation.SceneMomentMatching {
|
||||
@@ -149,6 +152,10 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
||||
err = fmt.Errorf("pan and mss scenes count not match")
|
||||
}
|
||||
|
||||
// var b bytes.Buffer
|
||||
// gocv.MatProfile.WriteTo(&b, 1)
|
||||
// fmt.Print(b.String())
|
||||
|
||||
return panScenes, mssScenes, err
|
||||
}
|
||||
|
||||
@@ -201,7 +208,7 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
// 输出 GeoJSON 数据
|
||||
log.Debug(string(data))
|
||||
|
||||
for i, scene := range mssScenes {
|
||||
for _, scene := range mssScenes {
|
||||
dir := filepath.Join(r.Params.OutputDir, scene.SceneIndex, "MSS")
|
||||
os.MkdirAll(dir, 0755)
|
||||
|
||||
@@ -211,6 +218,8 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
r.SetSceneBoundary(scene)
|
||||
|
||||
rgbirImage, _ := r.MergeMSSToBGRNIR(scene.Mat)
|
||||
defer rgbirImage.Close()
|
||||
|
||||
err := utils.SaveBGRToGDALGTiff(rgbirImage,
|
||||
4,
|
||||
scene.Meta.Corners.UpperLeft.Longitude,
|
||||
@@ -219,7 +228,6 @@ func (r *Registrator) SaveScenesToTiff(panScenes []*Scene, mssScenes []*Scene) e
|
||||
[]godal.ColorInterp{godal.CIBlue, godal.CIGreen, godal.CIRed, godal.CIUndefined},
|
||||
scene.Tiff)
|
||||
if err != nil {
|
||||
log.Errorf("save mss scene %d to tiff failed: %v", i+1, err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user