refactor
This commit is contained in:
34
cmd/proc.go
34
cmd/proc.go
@@ -45,20 +45,20 @@ var procCmd = &cobra.Command{
|
|||||||
calculator.EOP = calculator.NewEOPTable()
|
calculator.EOP = calculator.NewEOPTable()
|
||||||
calculator.EOP.Load(eopData, eopp5Line)
|
calculator.EOP.Load(eopData, eopp5Line)
|
||||||
|
|
||||||
reg := producer.NewRegistrator(producer.DownSampled)
|
processor := producer.NewImgProc(producer.DownSampled)
|
||||||
reg.Params = initParams()
|
processor.Params = initParams()
|
||||||
|
|
||||||
if err := reg.LoadAuxData(); err != nil {
|
if err := processor.LoadAuxData(); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// reg.AuxPrint()
|
// reg.AuxPrint()
|
||||||
|
|
||||||
if err := reg.LoadMssRaw(); err != nil {
|
if err := processor.LoadMssRaw(); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := reg.LoadPanRaw(); err != nil {
|
if err := processor.LoadPanRaw(); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,14 +71,14 @@ var procCmd = &cobra.Command{
|
|||||||
os.MkdirAll(params.OutputDir, 0755)
|
os.MkdirAll(params.OutputDir, 0755)
|
||||||
|
|
||||||
if doLUTRRC {
|
if doLUTRRC {
|
||||||
reg.DoRRCbyLUT(lutDir)
|
processor.DoRRCbyLUT(lutDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if doMomentMatching {
|
if doMomentMatching {
|
||||||
reg.DoMomentMatching()
|
processor.DoMomentMatching()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := reg.DoPhaseCorrelation(); err != nil {
|
if err := processor.DoPhaseCorrelation(); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,33 +87,33 @@ var procCmd = &cobra.Command{
|
|||||||
params.OutputDir,
|
params.OutputDir,
|
||||||
strings.TrimSuffix(filepath.Base(params.MssRawFile), filepath.Ext(params.MssRawFile))+"_registered.RAW",
|
strings.TrimSuffix(filepath.Base(params.MssRawFile), filepath.Ext(params.MssRawFile))+"_registered.RAW",
|
||||||
)
|
)
|
||||||
reg.SaveRegisteredMssToRaw(registerdMSSRAW)
|
processor.SaveRegisteredMssToRaw(registerdMSSRAW)
|
||||||
}
|
}
|
||||||
|
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
panScenes, mssScenes, err := reg.SubScenes()
|
panScenes, mssScenes, err := processor.SubScenes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
reg.OutputL1A(panScenes, mssScenes)
|
processor.OutputL1A(panScenes, mssScenes)
|
||||||
producer.CleanScenes(panScenes)
|
producer.CleanScenes(panScenes)
|
||||||
producer.CleanScenes(mssScenes)
|
producer.CleanScenes(mssScenes)
|
||||||
|
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
|
|
||||||
if saveStrip {
|
if saveStrip {
|
||||||
reg.SaveOriginalPanToGDALGTiff(reg.Params.PanTiffFile)
|
processor.SaveOriginalPanToGDALGTiff(processor.Params.PanTiffFile)
|
||||||
reg.SaveRegisteredMssToGDALGTiff(reg.Params.MssTiffFile)
|
processor.SaveRegisteredMssToGDALGTiff(processor.Params.MssTiffFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
if reg.Params.DoPansharpen {
|
if processor.Params.DoPansharpen {
|
||||||
reg.DoScenePansharpen(panScenes, mssScenes)
|
processor.DoScenePansharpen(panScenes, mssScenes)
|
||||||
}
|
}
|
||||||
|
|
||||||
reg.Report()
|
processor.Report()
|
||||||
|
|
||||||
reg.Clean()
|
processor.Clean()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"starwiz.cn/sjy01/image-proc/pkg/config"
|
"starwiz.cn/sjy01/image-proc/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Registrator) LoadAuxData() error {
|
func (r *ImgProc) LoadAuxData() error {
|
||||||
var err error
|
var err error
|
||||||
r.auxHeads, r.auxBoxes, r.AuxPlatforms, err = auxilary.ExtractAux(r.Params.AuxRawFile)
|
r.auxHeads, r.auxBoxes, r.AuxPlatforms, err = auxilary.ExtractAux(r.Params.AuxRawFile)
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ func (r *Registrator) LoadAuxData() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 数据校验和测试
|
// 数据校验和测试
|
||||||
func (r *Registrator) AuxPrint() {
|
func (r *ImgProc) AuxPrint() {
|
||||||
var fcPos84 geojson.FeatureCollection
|
var fcPos84 geojson.FeatureCollection
|
||||||
var fcPos84Interp geojson.FeatureCollection
|
var fcPos84Interp geojson.FeatureCollection
|
||||||
for _, p := range r.AuxPlatforms {
|
for _, p := range r.AuxPlatforms {
|
||||||
@@ -63,7 +63,7 @@ func (r *Registrator) AuxPrint() {
|
|||||||
f.Write(data)
|
f.Write(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) SceneImageTime(scene *Scene) (start, center, end time.Time) {
|
func (r *ImgProc) SceneImageTime(scene *Scene) (start, center, end time.Time) {
|
||||||
startPosInAux, endPosInAux := r.SceneInAuxIndex(scene)
|
startPosInAux, endPosInAux := r.SceneInAuxIndex(scene)
|
||||||
centerPosInAux := (startPosInAux + endPosInAux) / 2
|
centerPosInAux := (startPosInAux + endPosInAux) / 2
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ func (r *Registrator) SceneImageTime(scene *Scene) (start, center, end time.Time
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This function is not accurate enough. 四元数、成像时刻、GPS 等需要修改为插值获取
|
// FIXME: This function is not accurate enough. 四元数、成像时刻、GPS 等需要修改为插值获取
|
||||||
func (r *Registrator) ComputeMetaAndRPC(scene *Scene) (topLeft, bottomRight orb.Point) {
|
func (r *ImgProc) ComputeMetaAndRPC(scene *Scene) (topLeft, bottomRight orb.Point) {
|
||||||
log.Info("using attitude quaternion to calculate image boundary...")
|
log.Info("using attitude quaternion to calculate image boundary...")
|
||||||
line0Start := r.calculateLatLonH(scene, 0, 0, 0)
|
line0Start := r.calculateLatLonH(scene, 0, 0, 0)
|
||||||
line0End := r.calculateLatLonH(scene, 0, scene.Width, 0)
|
line0End := r.calculateLatLonH(scene, 0, scene.Width, 0)
|
||||||
@@ -169,13 +169,13 @@ func (r *Registrator) ComputeMetaAndRPC(scene *Scene) (topLeft, bottomRight orb.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) SceneInAuxIndex(scene *Scene) (int, int) {
|
func (r *ImgProc) SceneInAuxIndex(scene *Scene) (int, int) {
|
||||||
startPosInAux := r.sceneOffsetInAuxIndex(scene, 0)
|
startPosInAux := r.sceneOffsetInAuxIndex(scene, 0)
|
||||||
endPosInAux := r.sceneOffsetInAuxIndex(scene, scene.Height)
|
endPosInAux := r.sceneOffsetInAuxIndex(scene, scene.Height)
|
||||||
return startPosInAux, endPosInAux
|
return startPosInAux, endPosInAux
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) sceneOffsetInAuxIndex(scene *Scene, offset int) int {
|
func (r *ImgProc) sceneOffsetInAuxIndex(scene *Scene, offset int) int {
|
||||||
var auxForImageRow int
|
var auxForImageRow int
|
||||||
switch scene.Type {
|
switch scene.Type {
|
||||||
case "MSS":
|
case "MSS":
|
||||||
@@ -194,7 +194,7 @@ func (r *Registrator) sceneOffsetInAuxIndex(scene *Scene, offset int) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// row, col 相对于图像景左上角, H 为地面目标点高度
|
// row, col 相对于图像景左上角, H 为地面目标点高度
|
||||||
func (r *Registrator) calculateLatLonH(scene *Scene, row, col, H int) calculator.IntersectionPoint {
|
func (r *ImgProc) calculateLatLonH(scene *Scene, row, col, H int) calculator.IntersectionPoint {
|
||||||
// 内插值获取图像行时刻
|
// 内插值获取图像行时刻
|
||||||
ucam := col
|
ucam := col
|
||||||
cross := 16
|
cross := 16
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 暗场偏置校正 固定值15675校正
|
// 暗场偏置校正 固定值15675校正
|
||||||
func (r *Registrator) DoDarkBiasCorrection() {
|
func (r *ImgProc) DoDarkBiasCorrection() {
|
||||||
r.PanImage.SubtractFloat(DarkBiasValue)
|
r.PanImage.SubtractFloat(DarkBiasValue)
|
||||||
for i := 0; i < len(r.registeredMssImages); i++ {
|
for i := 0; i < len(r.registeredMssImages); i++ {
|
||||||
r.registeredMssImages[i].SubtractFloat(DarkBiasValue)
|
r.registeredMssImages[i].SubtractFloat(DarkBiasValue)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ const (
|
|||||||
|
|
||||||
type ResampleMethod string
|
type ResampleMethod string
|
||||||
|
|
||||||
type Registrator struct {
|
type ImgProc struct {
|
||||||
Params Params
|
Params Params
|
||||||
|
|
||||||
PanImage gocv.Mat
|
PanImage gocv.Mat
|
||||||
@@ -69,14 +69,14 @@ type Registrator struct {
|
|||||||
report Report
|
report Report
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRegistrator(rsmethod ResampleMethod) *Registrator {
|
func NewImgProc(rsmethod ResampleMethod) *ImgProc {
|
||||||
var r Registrator
|
var r ImgProc
|
||||||
r.resampleMethod = rsmethod
|
r.resampleMethod = rsmethod
|
||||||
|
|
||||||
return &r
|
return &r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) LoadPanRaw() error {
|
func (r *ImgProc) LoadPanRaw() error {
|
||||||
data, err := os.ReadFile(r.Params.PanRawFile)
|
data, err := os.ReadFile(r.Params.PanRawFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error reading raw file: ", err)
|
log.Error("Error reading raw file: ", err)
|
||||||
@@ -111,7 +111,7 @@ func (r *Registrator) LoadPanRaw() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) LoadMssRaw() error {
|
func (r *ImgProc) LoadMssRaw() error {
|
||||||
data, err := os.ReadFile(r.Params.MssRawFile)
|
data, err := os.ReadFile(r.Params.MssRawFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error reading raw file: ", err)
|
log.Error("Error reading raw file: ", err)
|
||||||
@@ -141,7 +141,7 @@ func (r *Registrator) LoadMssRaw() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) DoPhaseCorrelation() error {
|
func (r *ImgProc) DoPhaseCorrelation() error {
|
||||||
switch r.resampleMethod {
|
switch r.resampleMethod {
|
||||||
case UpSampled:
|
case UpSampled:
|
||||||
return r.CalcUpPhaseCorrelation()
|
return r.CalcUpPhaseCorrelation()
|
||||||
@@ -151,7 +151,7 @@ func (r *Registrator) DoPhaseCorrelation() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 将PAN降采样后计算相位相关的偏移量
|
// 将PAN降采样后计算相位相关的偏移量
|
||||||
func (r *Registrator) CalcDownPhaseCorrelation() error {
|
func (r *ImgProc) CalcDownPhaseCorrelation() error {
|
||||||
// 确保 MSS 高度是 PAN 高度的 1/4
|
// 确保 MSS 高度是 PAN 高度的 1/4
|
||||||
if r.MssHeight*4 != r.PanHeight {
|
if r.MssHeight*4 != r.PanHeight {
|
||||||
err := fmt.Errorf("MSS height is not 1/4 of PAN height, invalid raw file")
|
err := fmt.Errorf("MSS height is not 1/4 of PAN height, invalid raw file")
|
||||||
@@ -209,7 +209,7 @@ func (r *Registrator) CalcDownPhaseCorrelation() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 将MSS升采样采样后计算相位相关的偏移量
|
// 将MSS升采样采样后计算相位相关的偏移量
|
||||||
func (r *Registrator) CalcUpPhaseCorrelation() error {
|
func (r *ImgProc) CalcUpPhaseCorrelation() error {
|
||||||
log.Fatal("unsuppotted up-resample method")
|
log.Fatal("unsuppotted up-resample method")
|
||||||
// 确保 MSS 高度是 PAN 高度的 1/4
|
// 确保 MSS 高度是 PAN 高度的 1/4
|
||||||
if r.MssHeight*4 != r.PanHeight {
|
if r.MssHeight*4 != r.PanHeight {
|
||||||
@@ -249,7 +249,7 @@ func (r *Registrator) CalcUpPhaseCorrelation() error {
|
|||||||
return r.DoPANCoRegistration()
|
return r.DoPANCoRegistration()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) doPhaseCorrelation(base gocv.Mat,
|
func (r *ImgProc) doPhaseCorrelation(base gocv.Mat,
|
||||||
mssImages []gocv.Mat,
|
mssImages []gocv.Mat,
|
||||||
height, width,
|
height, width,
|
||||||
blockHeight, blockWidth int) error {
|
blockHeight, blockWidth int) error {
|
||||||
@@ -327,7 +327,7 @@ func (r *Registrator) doPhaseCorrelation(base gocv.Mat,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) Clean() {
|
func (r *ImgProc) Clean() {
|
||||||
r.PanImage.Close()
|
r.PanImage.Close()
|
||||||
for i := 0; i < MssBands; i++ {
|
for i := 0; i < MssBands; i++ {
|
||||||
r.MssImages[i].Close()
|
r.MssImages[i].Close()
|
||||||
@@ -340,7 +340,7 @@ func (r *Registrator) Clean() {
|
|||||||
r.rgbirImage.Close()
|
r.rgbirImage.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) calcMSSDeltaCoeffs(bands int) error {
|
func (r *ImgProc) calcMSSDeltaCoeffs(bands int) error {
|
||||||
// 计算每个通道的delta多项式拟合系数
|
// 计算每个通道的delta多项式拟合系数
|
||||||
for i := 0; i < bands; i++ {
|
for i := 0; i < bands; i++ {
|
||||||
var cx []float64
|
var cx []float64
|
||||||
@@ -397,7 +397,7 @@ func (r *Registrator) calcMSSDeltaCoeffs(bands int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) DoMSSCoRegistration(byEdge bool) error {
|
func (r *ImgProc) DoMSSCoRegistration(byEdge bool) error {
|
||||||
for band := 0; band < MssBands; band++ {
|
for band := 0; band < MssBands; band++ {
|
||||||
if len(r.deltaXCoeffs[band]) < 2 || len(r.deltaYCoeffs[band]) < 3 {
|
if len(r.deltaXCoeffs[band]) < 2 || len(r.deltaYCoeffs[band]) < 3 {
|
||||||
log.Errorf("delta coefficients not calculated, skip co-registration %d", band+1)
|
log.Errorf("delta coefficients not calculated, skip co-registration %d", band+1)
|
||||||
@@ -456,7 +456,7 @@ func (r *Registrator) DoMSSCoRegistration(byEdge bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) DoPANCoRegistration() error {
|
func (r *ImgProc) DoPANCoRegistration() error {
|
||||||
if len(r.deltaXCoeffs[0]) < 2 || len(r.deltaYCoeffs[0]) < 3 {
|
if len(r.deltaXCoeffs[0]) < 2 || len(r.deltaYCoeffs[0]) < 3 {
|
||||||
log.Error("delta coefficients not calculated, skip co-registration")
|
log.Error("delta coefficients not calculated, skip co-registration")
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ func (corners Corners) Extend() (lng1, lat1, lng2, lat2 float64) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) makeProductMeta(scene *Scene) *ProductMeta {
|
func (r *ImgProc) makeProductMeta(scene *Scene) *ProductMeta {
|
||||||
meta := &ProductMeta{
|
meta := &ProductMeta{
|
||||||
Satellite: "SJY01",
|
Satellite: "SJY01",
|
||||||
Sensor: "PMS",
|
Sensor: "PMS",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
"starwiz.cn/sjy01/image-proc/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Registrator) SaveOriginalPanToGDALGTiff(tiffFile string) error {
|
func (r *ImgProc) SaveOriginalPanToGDALGTiff(tiffFile string) error {
|
||||||
err := utils.SavePanToGDALGTiff(r.PanImage, 0, 0, tiffFile, PanResolution)
|
err := utils.SavePanToGDALGTiff(r.PanImage, 0, 0, tiffFile, PanResolution)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -22,7 +22,7 @@ func (r *Registrator) SaveOriginalPanToGDALGTiff(tiffFile string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) SaveRegisteredMssToGDALGTiff(tiffFile string) error {
|
func (r *ImgProc) SaveRegisteredMssToGDALGTiff(tiffFile string) error {
|
||||||
r.rgbirImage = gocv.NewMat()
|
r.rgbirImage = gocv.NewMat()
|
||||||
gocv.Merge(r.registeredMssImages[:], &r.rgbirImage)
|
gocv.Merge(r.registeredMssImages[:], &r.rgbirImage)
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ func (r *Registrator) SaveRegisteredMssToGDALGTiff(tiffFile string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) BytesToRaw(mssData []byte, filePath string) error {
|
func (r *ImgProc) BytesToRaw(mssData []byte, filePath string) error {
|
||||||
f, err := os.OpenFile(filePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
|
f, err := os.OpenFile(filePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -48,15 +48,15 @@ func (r *Registrator) BytesToRaw(mssData []byte, filePath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) SaveRegisteredMssToRaw(raw string) error {
|
func (r *ImgProc) SaveRegisteredMssToRaw(raw string) error {
|
||||||
return saveRegisteredMssToRaw(raw, r.registeredMssImages)
|
return saveRegisteredMssToRaw(raw, r.registeredMssImages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) Report() error {
|
func (r *ImgProc) Report() error {
|
||||||
return WriteReport(&r.report, r.Params.ReportFile)
|
return WriteReport(&r.report, r.Params.ReportFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) rpcKeywordInTif() {
|
func (r *ImgProc) rpcKeywordInTif() {
|
||||||
// GDAL库对应的RPC关键词
|
// GDAL库对应的RPC关键词
|
||||||
// keys := []string{
|
// keys := []string{
|
||||||
// "ERR_BIAS", "ERR_RAND",
|
// "ERR_BIAS", "ERR_RAND",
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type Block struct {
|
|||||||
coord image.Point // top-left corner of the block in the original image
|
coord image.Point // top-left corner of the block in the original image
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) calculateBlockPhaseShift(panBlock, mssBlock gocv.Mat) (gocv.Point2f, float64) {
|
func (r *ImgProc) calculateBlockPhaseShift(panBlock, mssBlock gocv.Mat) (gocv.Point2f, float64) {
|
||||||
pan := gocv.NewMat()
|
pan := gocv.NewMat()
|
||||||
mss := gocv.NewMat()
|
mss := gocv.NewMat()
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ func (r *Registrator) calculateBlockPhaseShift(panBlock, mssBlock gocv.Mat) (goc
|
|||||||
return shift, response
|
return shift, response
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) fileterPhaseShift(thredholds []float64, greaterThan bool) error {
|
func (r *ImgProc) fileterPhaseShift(thredholds []float64, greaterThan bool) error {
|
||||||
if len(thredholds) > 4 {
|
if len(thredholds) > 4 {
|
||||||
return errors.New("thredholds length should be less than 4")
|
return errors.New("thredholds length should be less than 4")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ type RPC struct {
|
|||||||
gridsize int
|
gridsize int
|
||||||
|
|
||||||
scene *Scene
|
scene *Scene
|
||||||
registrator *Registrator
|
registrator *ImgProc
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroundPoint 表示地面点的三维坐标
|
// GroundPoint 表示地面点的三维坐标
|
||||||
@@ -53,7 +53,7 @@ type RPCModel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// rational polynomial coeffients
|
// rational polynomial coeffients
|
||||||
func NewRPC(r *Registrator, scene *Scene) *RPC {
|
func NewRPC(r *ImgProc, scene *Scene) *RPC {
|
||||||
rpc := RPC{
|
rpc := RPC{
|
||||||
elevationLayer: config.GCONFIG.RPC.AltitudeLayer,
|
elevationLayer: config.GCONFIG.RPC.AltitudeLayer,
|
||||||
gridsize: config.GCONFIG.RPC.GridSize,
|
gridsize: config.GCONFIG.RPC.GridSize,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"starwiz.cn/sjy01/image-proc/pkg/rrc"
|
"starwiz.cn/sjy01/image-proc/pkg/rrc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Registrator) DoRRCbyLUT(lutDir string) error {
|
func (r *ImgProc) DoRRCbyLUT(lutDir string) error {
|
||||||
logrus.Printf("try to do RRC [%s]...", lutDir)
|
logrus.Printf("try to do RRC [%s]...", lutDir)
|
||||||
lutPAN, err := rrc.LoadLUT(filepath.Join(lutDir, "B0.LUT"), 9344)
|
lutPAN, err := rrc.LoadLUT(filepath.Join(lutDir, "B0.LUT"), 9344)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -42,7 +42,7 @@ func (r *Registrator) DoRRCbyLUT(lutDir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) DoMomentMatching() error {
|
func (r *ImgProc) DoMomentMatching() error {
|
||||||
rrc.DoMomentMatching(r.PanImage)
|
rrc.DoMomentMatching(r.PanImage)
|
||||||
for i := 0; i < 4; i++ {
|
for i := 0; i < 4; i++ {
|
||||||
rrc.DoMomentMatching(r.MssImages[i])
|
rrc.DoMomentMatching(r.MssImages[i])
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func CleanScenes(scenes []*Scene) {
|
|||||||
// 默认分景大小:
|
// 默认分景大小:
|
||||||
// MSS 2336 * 2336 - 1764
|
// MSS 2336 * 2336 - 1764
|
||||||
// PAN 9344 * 9344 - 7056
|
// PAN 9344 * 9344 - 7056
|
||||||
func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err error) {
|
func (r *ImgProc) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err error) {
|
||||||
if len(r.Params.Targets.Targets) > 0 && r.Params.Targets.Targets[0].EndLine > 0 {
|
if len(r.Params.Targets.Targets) > 0 && r.Params.Targets.Targets[0].EndLine > 0 {
|
||||||
return r.RoiScenes()
|
return r.RoiScenes()
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ func (r *Registrator) SubScenes() (panScenes []*Scene, mssScenes []*Scene, err e
|
|||||||
return panScenes, mssScenes, err
|
return panScenes, mssScenes, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) OutputL1A(panScenes []*Scene, mssScenes []*Scene) error {
|
func (r *ImgProc) OutputL1A(panScenes []*Scene, mssScenes []*Scene) error {
|
||||||
var fc geojson.FeatureCollection
|
var fc geojson.FeatureCollection
|
||||||
for i, scene := range panScenes {
|
for i, scene := range panScenes {
|
||||||
dir := filepath.Join(r.Params.OutputDir, scene.SceneIndex, "PAN")
|
dir := filepath.Join(r.Params.OutputDir, scene.SceneIndex, "PAN")
|
||||||
@@ -247,7 +247,7 @@ func (r *Registrator) OutputL1A(panScenes []*Scene, mssScenes []*Scene) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) DoScenePansharpen(panScenes []*Scene, mssScenes []*Scene) error {
|
func (r *ImgProc) DoScenePansharpen(panScenes []*Scene, mssScenes []*Scene) error {
|
||||||
for i := 0; i < len(panScenes); i++ {
|
for i := 0; i < len(panScenes); i++ {
|
||||||
fusedTiff := strings.Replace(mssScenes[i].Tiff, "MSS", "FUS", -1)
|
fusedTiff := strings.Replace(mssScenes[i].Tiff, "MSS", "FUS", -1)
|
||||||
err := fusion.Pansharpen(panScenes[i].Tiff, mssScenes[i].Tiff, fusedTiff, fusion.ESRI, 0.1)
|
err := fusion.Pansharpen(panScenes[i].Tiff, mssScenes[i].Tiff, fusedTiff, fusion.ESRI, 0.1)
|
||||||
@@ -266,7 +266,7 @@ func (r *Registrator) DoScenePansharpen(panScenes []*Scene, mssScenes []*Scene)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) MergeMSSToBGRNIR(channels []gocv.Mat) (gocv.Mat, error) {
|
func (r *ImgProc) MergeMSSToBGRNIR(channels []gocv.Mat) (gocv.Mat, error) {
|
||||||
var rgbirImage gocv.Mat
|
var rgbirImage gocv.Mat
|
||||||
if len(channels) != 4 {
|
if len(channels) != 4 {
|
||||||
return rgbirImage, fmt.Errorf("mss channels count not match")
|
return rgbirImage, fmt.Errorf("mss channels count not match")
|
||||||
@@ -281,7 +281,7 @@ func (r *Registrator) MergeMSSToBGRNIR(channels []gocv.Mat) (gocv.Mat, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Registrator) RoiScenes() (panScenes []*Scene, mssScenes []*Scene, err error) {
|
func (r *ImgProc) RoiScenes() (panScenes []*Scene, mssScenes []*Scene, err error) {
|
||||||
log.Println("using target scenes")
|
log.Println("using target scenes")
|
||||||
for _, target := range r.Params.Targets.Targets {
|
for _, target := range r.Params.Targets.Targets {
|
||||||
y0 := 4 * target.StartLine
|
y0 := 4 * target.StartLine
|
||||||
|
|||||||
Reference in New Issue
Block a user