Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Siril Star Detector #434

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import nebulosa.pixinsight.script.PixInsightIsRunning
import nebulosa.pixinsight.script.PixInsightScriptRunner
import nebulosa.pixinsight.script.PixInsightStartup
import nebulosa.pixinsight.stardetector.PixInsightStarDetector
import nebulosa.siril.stardetector.SirilStarDetector
import nebulosa.stardetector.StarDetector
import java.nio.file.Path
import java.time.Duration
Expand All @@ -15,11 +16,13 @@ data class StarDetectionRequest(
@JvmField val executablePath: Path? = null,
@JvmField val timeout: Duration = Duration.ZERO,
@JvmField val minSNR: Double = 0.0,
@JvmField val maxStars: Int = 0,
@JvmField val slot: Int = 1,
) : Supplier<StarDetector<Path>> {

override fun get() = when (type) {
StarDetectorType.ASTAP -> AstapStarDetector(executablePath!!, minSNR)
StarDetectorType.SIRIL -> SirilStarDetector(executablePath!!, maxStars)
StarDetectorType.PIXINSIGHT -> {
val runner = PixInsightScriptRunner(executablePath!!)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package nebulosa.api.stardetector

enum class StarDetectorType {
ASTAP,
PIXINSIGHT
PIXINSIGHT,
SIRIL,
}
4 changes: 2 additions & 2 deletions desktop/src/app/alignment/alignment.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Angle } from '../../shared/types/atlas.types'
import { Camera, EMPTY_CAMERA, EMPTY_CAMERA_START_CAPTURE, ExposureTimeUnit, updateCameraStartCaptureFromCamera } from '../../shared/types/camera.types'
import { EMPTY_GUIDE_OUTPUT, GuideDirection, GuideOutput } from '../../shared/types/guider.types'
import { EMPTY_MOUNT, Mount } from '../../shared/types/mount.types'
import { EMPTY_PLATE_SOLVER_OPTIONS } from '../../shared/types/settings.types'
import { EMPTY_PLATE_SOLVER_REQUEST } from '../../shared/types/settings.types'
import { deviceComparator } from '../../shared/utils/comparators'
import { AppComponent } from '../app.component'
import { CameraComponent } from '../camera/camera.component'
Expand Down Expand Up @@ -40,7 +40,7 @@ export class AlignmentComponent implements AfterViewInit, OnDestroy, Pingable {

readonly tppaRequest: TPPAStart = {
capture: structuredClone(EMPTY_CAMERA_START_CAPTURE),
plateSolver: structuredClone(EMPTY_PLATE_SOLVER_OPTIONS),
plateSolver: structuredClone(EMPTY_PLATE_SOLVER_REQUEST),
startFromCurrentPosition: true,
stepDirection: 'EAST',
compensateRefraction: true,
Expand Down
9 changes: 8 additions & 1 deletion desktop/src/app/image/image.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,20 @@
<label>Detector</label>
</span>
</div>
<div class="col-5 align-items-center">
<div class="col-5 align-items-center" *ngIf="starDetection.type !== 'SIRIL'">
<span class="p-float-label">
<p-inputNumber [min]="0" [max]="500" [step]="1" [showButtons]="true" class="w-full" styleClass="p-inputtext-sm border-0 w-full"
[(ngModel)]="starDetection.minSNR" locale="en" [allowEmpty]="false" scrollableNumber />
<label>Min SNR</label>
</span>
</div>
<div class="col-5 align-items-center" *ngIf="starDetection.type === 'SIRIL'">
<span class="p-float-label">
<p-inputNumber [min]="0" [max]="2000" [step]="1" [showButtons]="true" class="w-full" styleClass="p-inputtext-sm border-0 w-full"
[(ngModel)]="starDetection.maxStars" locale="en" [allowEmpty]="false" scrollableNumber />
<label>Max Stars</label>
</span>
</div>
<div class="col-12 mt-1">
<span class="font-bold text-sm">COMPUTED</span>
</div>
Expand Down
36 changes: 24 additions & 12 deletions desktop/src/app/image/image.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class ImageComponent implements AfterViewInit, OnDestroy {
running: false,
type: 'ASTAP',
minSNR: 0,
maxStars: 0,
visible: false,
stars: [],
computed: {
Expand Down Expand Up @@ -799,6 +800,7 @@ export class ImageComponent implements AfterViewInit, OnDestroy {
async detectStars() {
const options = this.preference.starDetectionRequest(this.starDetection.type).get()
options.minSNR = this.starDetection.minSNR
options.maxStars = this.starDetection.maxStars

try {
this.starDetection.running = true
Expand Down Expand Up @@ -919,8 +921,8 @@ export class ImageComponent implements AfterViewInit, OnDestroy {
}
}

this.solver.focalLength ||= imagePreference.solverFocalLength || 0
this.solver.pixelSize ||= imagePreference.solverPixelSize || 0
this.solver.focalLength ||= imagePreference.solver?.focalLength || 0
this.solver.pixelSize ||= imagePreference.solver?.pixelSize || 0
}

imageClicked(event: MouseEvent, contextMenu: boolean) {
Expand Down Expand Up @@ -1273,23 +1275,33 @@ export class ImageComponent implements AfterViewInit, OnDestroy {

private loadPreference() {
const preference = this.preference.imagePreference.get()
this.solver.radius = preference.solverRadius ?? this.solver.radius
this.solver.type = preference.solverType ?? 'ASTAP'
this.starDetection.type = preference.starDetectionType ?? this.starDetection.type
this.starDetection.minSNR = preference.starDetectionMinSNR ?? this.preference.starDetectionRequest(this.starDetection.type).get().minSNR ?? this.starDetection.minSNR
this.solver.radius = preference.solver?.radius ?? this.solver.radius
this.solver.type = preference.solver?.type ?? 'ASTAP'
this.solver.focalLength = preference.solver?.focalLength ?? 0
this.solver.pixelSize = preference.solver?.pixelSize ?? 0
this.starDetection.type = preference.starDetection?.type ?? this.starDetection.type
this.starDetection.minSNR = preference.starDetection?.minSNR ?? this.preference.starDetectionRequest(this.starDetection.type).get().minSNR ?? this.starDetection.minSNR
this.starDetection.maxStars = preference.starDetection?.maxStars ?? this.preference.starDetectionRequest(this.starDetection.type).get().maxStars ?? this.starDetection.maxStars

this.fov.fovs = this.preference.imageFOVs.get()
this.fov.fovs.forEach(e => { e.enabled = false; e.computed = undefined })
}

private savePreference() {
const preference = this.preference.imagePreference.get()
preference.solverRadius = this.solver.radius
preference.solverType = this.solver.type
preference.solverPixelSize = this.solver.pixelSize
preference.solverFocalLength = this.solver.focalLength
preference.starDetectionType = this.starDetection.type
preference.starDetectionMinSNR = this.starDetection.minSNR

preference.solver = {
type: this.solver.type,
focalLength: this.solver.focalLength,
pixelSize: this.solver.pixelSize,
radius: this.solver.radius,
}
preference.starDetection = {
type: this.starDetection.type,
maxStars: this.starDetection.maxStars,
minSNR: this.starDetection.minSNR,
}

this.preference.imagePreference.set(preference)
}

Expand Down
11 changes: 10 additions & 1 deletion desktop/src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
[path]="starDetectors.get(starDetectorType)!.executablePath" class="w-full"
(pathChange)="starDetectors.get(starDetectorType)!.executablePath = $event; save()" />
</div>
<div class="col-4">
<div class="col-4" *ngIf="starDetectorType !== 'SIRIL'">
<span class="p-float-label">
<p-inputNumber [min]="0" [max]="500" [step]="1" [showButtons]="true" class="w-full" styleClass="p-inputtext-sm border-0 w-full"
[ngModel]="starDetectors.get(starDetectorType)!.minSNR"
Expand All @@ -97,6 +97,15 @@
<label>Min SNR</label>
</span>
</div>
<div class="col-4" *ngIf="starDetectorType === 'SIRIL'">
<span class="p-float-label">
<p-inputNumber [min]="0" [max]="2000" [step]="1" [showButtons]="true" class="w-full" styleClass="p-inputtext-sm border-0 w-full"
[ngModel]="starDetectors.get(starDetectorType)!.maxStars"
(ngModelChange)="starDetectors.get(starDetectorType)!.maxStars = $event; save()" locale="en" [allowEmpty]="false"
scrollableNumber />
<label>Max stars</label>
</span>
</div>
<div class="col-4">
<span class="p-float-label">
<p-inputNumber styleClass="p-inputtext-sm border-0 w-full" [ngModel]="starDetectors.get(starDetectorType)!.timeout"
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PreferenceService } from '../../shared/services/preference.service'
import { PrimeService } from '../../shared/services/prime.service'
import { EMPTY_LOCATION, Location } from '../../shared/types/atlas.types'
import { LiveStackerType, LiveStackingRequest } from '../../shared/types/camera.types'
import { PlateSolverOptions, PlateSolverType, StarDetectionOptions, StarDetectorType } from '../../shared/types/settings.types'
import { PlateSolverRequest, PlateSolverType, StarDetectionRequest, StarDetectorType } from '../../shared/types/settings.types'
import { AppComponent } from '../app.component'

@Component({
Expand Down Expand Up @@ -40,10 +40,10 @@ export class SettingsComponent implements AfterViewInit, OnDestroy {
location: Location

plateSolverType: PlateSolverType = 'ASTAP'
readonly plateSolvers = new Map<PlateSolverType, PlateSolverOptions>()
readonly plateSolvers = new Map<PlateSolverType, PlateSolverRequest>()

starDetectorType: StarDetectorType = 'ASTAP'
readonly starDetectors = new Map<StarDetectorType, StarDetectionOptions>()
readonly starDetectors = new Map<StarDetectorType, StarDetectionRequest>()

liveStackerType: LiveStackerType = 'SIRIL'
readonly liveStackers = new Map<LiveStackerType, LiveStackingRequest>()
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/shared/pipes/dropdown-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DropdownOptionsPipe implements PipeTransform {

transform<K extends keyof DropdownOptions>(type: K): DropdownOptions[K] {
switch (type) {
case 'STAR_DETECTOR': return ['ASTAP', 'PIXINSIGHT'] as DropdownOptions[K]
case 'STAR_DETECTOR': return ['ASTAP', 'PIXINSIGHT', 'SIRIL'] as DropdownOptions[K]
case 'PLATE_SOLVER': return ['ASTAP', 'ASTROMETRY_NET_ONLINE', 'SIRIL'] as DropdownOptions[K]
case 'AUTO_FOCUS_FITTING_MODE': return ['TRENDLINES', 'PARABOLIC', 'TREND_PARABOLIC', 'HYPERBOLIC', 'TREND_HYPERBOLIC'] as DropdownOptions[K]
case 'AUTO_FOCUS_BACKLASH_COMPENSATION_MODE': return ['NONE', 'ABSOLUTE', 'OVERSHOOT'] as DropdownOptions[K]
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/shared/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { CoordinateInterpolation, DetectedStar, FOVCamera, FOVTelescope, ImageAn
import { CelestialLocationType, Mount, MountRemoteControl, MountRemoteControlType, SlewRate, TrackMode } from '../types/mount.types'
import { Rotator } from '../types/rotator.types'
import { SequencePlan } from '../types/sequencer.types'
import { PlateSolverOptions, StarDetectionOptions } from '../types/settings.types'
import { PlateSolverRequest, StarDetectionRequest } from '../types/settings.types'
import { FilterWheel } from '../types/wheel.types'
import { HttpService } from './http.service'

Expand Down Expand Up @@ -563,7 +563,7 @@ export class ApiService {
return this.http.get<CoordinateInterpolation | null>(`image/coordinate-interpolation?${query}`)
}

detectStars(path: string, starDetector: StarDetectionOptions) {
detectStars(path: string, starDetector: StarDetectionRequest) {
const query = this.http.query({ path })
return this.http.put<DetectedStar[]>(`star-detection?${query}`, starDetector)
}
Expand Down Expand Up @@ -672,7 +672,7 @@ export class ApiService {
// SOLVER

solveImage(
solver: PlateSolverOptions, path: string, blind: boolean,
solver: PlateSolverRequest, path: string, blind: boolean,
centerRA: Angle, centerDEC: Angle, radius: Angle,
) {
const query = this.http.query({ path, blind, centerRA, centerDEC, radius })
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/shared/services/preference.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Focuser, FocuserPreference } from '../types/focuser.types'
import { ConnectionDetails, Equipment, HomePreference } from '../types/home.types'
import { EMPTY_IMAGE_PREFERENCE, FOV, ImagePreference } from '../types/image.types'
import { Rotator, RotatorPreference } from '../types/rotator.types'
import { EMPTY_PLATE_SOLVER_OPTIONS, EMPTY_STAR_DETECTION_OPTIONS, PlateSolverOptions as PlateSolverRequest, PlateSolverType, StarDetectionOptions as StarDetectionRequest, StarDetectorType } from '../types/settings.types'
import { EMPTY_PLATE_SOLVER_REQUEST, EMPTY_STAR_DETECTION_REQUEST, PlateSolverRequest, PlateSolverType, StarDetectionRequest, StarDetectorType } from '../types/settings.types'
import { FilterWheel, WheelPreference } from '../types/wheel.types'
import { LocalStorageService } from './local-storage.service'

Expand Down Expand Up @@ -69,11 +69,11 @@ export class PreferenceService {
}

plateSolverRequest(type: PlateSolverType) {
return new PreferenceData<PlateSolverRequest>(this.storage, `plateSolver.${type}`, () => <PlateSolverRequest>{ ...EMPTY_PLATE_SOLVER_OPTIONS, type })
return new PreferenceData<PlateSolverRequest>(this.storage, `plateSolver.${type}`, () => <PlateSolverRequest>{ ...EMPTY_PLATE_SOLVER_REQUEST, type })
}

starDetectionRequest(type: StarDetectorType) {
return new PreferenceData<StarDetectionRequest>(this.storage, `starDetection.${type}`, () => <StarDetectionRequest>{ ...EMPTY_STAR_DETECTION_OPTIONS, type })
return new PreferenceData<StarDetectionRequest>(this.storage, `starDetection.${type}`, () => <StarDetectionRequest>{ ...EMPTY_STAR_DETECTION_REQUEST, type })
}

liveStackingRequest(type: LiveStackerType) {
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/shared/types/alignment.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Angle } from './atlas.types'
import { Camera, CameraCaptureEvent, CameraStartCapture } from './camera.types'
import { GuideDirection } from './guider.types'
import { PlateSolverOptions, PlateSolverType } from './settings.types'
import { PlateSolverRequest, PlateSolverType } from './settings.types'

export type Hemisphere = 'NORTHERN' | 'SOUTHERN'

Expand Down Expand Up @@ -52,7 +52,7 @@ export interface DARVEvent extends MessageEvent {

export interface TPPAStart {
capture: CameraStartCapture
plateSolver: PlateSolverOptions
plateSolver: PlateSolverRequest
startFromCurrentPosition: boolean
compensateRefraction: boolean
stopTrackingWhenDone: boolean
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/shared/types/autofocus.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Point } from 'electron'
import { CameraCaptureEvent, CameraStartCapture } from './camera.types'
import { EMPTY_STAR_DETECTION_OPTIONS, StarDetectionOptions } from './settings.types'
import { EMPTY_STAR_DETECTION_REQUEST, StarDetectionRequest } from './settings.types'

export type AutoFocusState = 'IDLE' | 'MOVING' | 'EXPOSURING' | 'EXPOSURED' | 'ANALYSING' | 'ANALYSED' | 'CURVE_FITTED' | 'FAILED' | 'FINISHED'

Expand All @@ -22,7 +22,7 @@ export interface AutoFocusRequest {
initialOffsetSteps: number
stepSize: number
totalNumberOfAttempts: number
starDetector: StarDetectionOptions
starDetector: StarDetectionRequest
}

export interface AutoFocusPreference extends Omit<AutoFocusRequest, 'capture'> { }
Expand All @@ -38,7 +38,7 @@ export const EMPTY_AUTO_FOCUS_PREFERENCE: AutoFocusPreference = {
backlashIn: 0,
backlashOut: 0
},
starDetector: EMPTY_STAR_DETECTION_OPTIONS,
starDetector: EMPTY_STAR_DETECTION_REQUEST,
}

export interface Curve {
Expand Down
43 changes: 25 additions & 18 deletions desktop/src/shared/types/image.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Point, Size } from 'electron'
import { Angle, AstronomicalObject, DeepSkyObject, EquatorialCoordinateJ2000, Star } from './atlas.types'
import { Camera, CameraStartCapture } from './camera.types'
import { PlateSolverType, StarDetectorType } from './settings.types'
import { PlateSolverRequest, StarDetectionRequest } from './settings.types'

export type ImageChannel = 'RED' | 'GREEN' | 'BLUE' | 'GRAY'

Expand Down Expand Up @@ -111,20 +111,33 @@ export interface ImageStatistics {
maximum: number
}

export interface StarDetectionImagePreference extends Pick<StarDetectionRequest, 'type' | 'minSNR' | 'maxStars'> {
}

export interface PlateSolverImagePreference extends Pick<PlateSolverRequest, 'type'> {
radius: number
focalLength: number
pixelSize: number
}

export interface ImagePreference {
solverRadius?: number
solverType?: PlateSolverType
solverFocalLength?: number
solverPixelSize?: number
savePath?: string
starDetectionType?: StarDetectorType
starDetectionMinSNR?: number
solver?: PlateSolverImagePreference
starDetection?: StarDetectionImagePreference
}

export const EMPTY_IMAGE_PREFERENCE: ImagePreference = {
solverRadius: 4,
solverType: 'ASTAP',
starDetectionType: 'ASTAP'
solver: {
type: 'ASTAP',
radius: 4,
focalLength: 0,
pixelSize: 0,
},
starDetection: {
type: 'ASTAP',
minSNR: 0,
maxStars: 0,
}
}

export interface ImageData {
Expand Down Expand Up @@ -210,17 +223,13 @@ export interface ImageStretchDialog {
midtone: number
}

export interface ImageSolverDialog {
export interface ImageSolverDialog extends PlateSolverImagePreference {
showDialog: boolean
running: boolean
blind: boolean
centerRA: Angle
centerDEC: Angle
radius: number
focalLength: number
pixelSize: number
readonly solved: ImageSolved
type: PlateSolverType
}

export interface ImageFOVDialog extends FOV {
Expand Down Expand Up @@ -281,11 +290,9 @@ export interface ROISelected {
height: number
}

export interface StarDetectionDialog {
export interface StarDetectionDialog extends StarDetectionImagePreference {
showDialog: boolean
running: boolean
type: StarDetectorType
minSNR: number
visible: boolean
stars: DetectedStar[]
computed: Omit<DetectedStar, 'x' | 'y' | 'flux'> & { minFlux: number, maxFlux: number }
Expand Down
Loading