Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Swift: Intervalo de tiempo de ARKit hasta la fecha

El cuadro ARFrame currentFrame de ARSession tiene un atributo de timestamp de tiempo de tipo TimeInterval que representa el tiempo de actividad en el momento en que se capturó el cuadro.

Necesito convertir este TimeInterval al dominio de tiempo actual del dispositivo.

Si mi suposición sobre la timestamp de tiempo es correcta, agregar el BootTime y la timestamp de tiempo del núcleo me daría la fecha correcta.

Problema: Agregar el kernel BootTime y la timestamp de tiempo juntos me da una fecha que no es correcta. (dependiendo del último tiempo de arranque del dispositivo, hasta 2 días de variación)

Código actual:

 func kernelBootTime() -> Date { var mib = [CTL_KERN, KERN_BOOTTIME] var bootTime = timeval() var bootTimeSize = MemoryLayout<timeval>.stride if sysctl(&mib, UInt32(mib.count), &bootTime, &bootTimeSize, nil, 0) != 0 { fatalError("Could not get boot time, errno: \(errno)") } return Date(timeIntervalSince1970: Double(bootTime.tv_sec) + Double(bootTime.tv_usec) / 1_000_000.0) } public func checkTime(_ session: ARSession) { guard let frame = session.currentFrame else { return } print(Date(timeInterval: frame.timestamp, since: kernelBootTime())) }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Encontré la solución.

 var refDate = Date.now - ProcessInfo.processInfo.systemUptime

te da la fecha del último reinicio del dispositivo

 public func checkTime(_ session: ARSession) { guard let frame = session.currentFrame else { return } print(Date(timeInterval: frame.timestamp, since: refDate)) }

imprime la hora exacta en que se tomó la imagen. (en hora UTC)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!