Forum

Author Topic: Segmentation fault matchPhotos  (Read 3110 times)

zoocafe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Segmentation fault matchPhotos
« on: December 14, 2017, 05:46:39 AM »
When I run photoscan.sh -platform offscreen -r script.py I most of the time get segmentation fault
photoscan.sh: line 19: 27666 Segmentation fault      (core dumped) "$dirname/$appname" "$@"

It appears when I do chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection=True,reference_preselection=False) after addPhotos.

AddPhotos
MatchPhotos: accuracy = High, preselection = generic, keypoint limit = 40000, tiepoint limit = 4000, constrain features by mask = 0
photoscan.sh: line 19: 21670 Segmentation fault      (core dumped) "$dirname/$appname" "$@"


Now and then it works without segmentation fault but it is rare

I've tried version 1.3.4, 1.3.3 and 1.3.2 but the result are the same

I'm certain that the list of photos for addPhotos is valid as I create it from os.list.dir and have confirmed the paths.
Even though I don't think it is the root problem is there a way for photoscan to check or return the number of added photos or their paths?

I'm running this on a server without CPU
model name   : Intel(R) Xeon(R) CPU E5-26xx v4
cpu MHz      : 2394.446
cache size   : 4096 KB
Linux VM_154_79_centos 2.6.32-642.6.2.el6.x86_64

Segmentation fault in bold below
--- script.py start ---
import PhotoScan
import os
import json
import datetime

def timestampAndAppendTextToFile(text, file):
    stamp = datetime.datetime.now()
    stamp = str(stamp) + " " + text + os.linesep
    f=open(file, 'a+')
    f.write(stamp)
    f.close()


photoFolder = "imgs"
doc = PhotoScan.app.document
scriptdir = os.path.dirname(os.path.abspath(__file__))
logFile = os.path.join(scriptdir, "job.log")
doc.save(os.path.join(scriptdir, "psproject.psz"))
chunk = PhotoScan.app.document.addChunk()

# Get images in the folder
imgFolder = os.path.join(scriptdir, photoFolder)
print(scriptdir)
print(imgFolder)
includedExts = ['jpg', 'jpeg', 'png', 'tif']

file_names = []
for fn in os.listdir(imgFolder):
    fnlower = fn.lower()
    if any(fnlower.endswith(ext) for ext in includedExts):
        file_names.append(os.path.join(imgFolder,fn))

timestampAndAppendTextToFile("Number of photos:" + str(len(file_names)), logFile)

timestampAndAppendTextToFile("Photos - start", logFile)
for fn in file_names:
    timestampAndAppendTextToFile(fn, logFile)
timestampAndAppendTextToFile("Photos - end", logFile)

# Add processing server
GPUdevices = PhotoScan.app.enumGPUDevices()
prettyJson = json.dumps(GPUdevices, indent=2)
timestampAndAppendTextToFile(str(prettyJson), logFile)

try:
    chunk.addPhotos(file_names)
    timestampAndAppendTextToFile("Success Add photos done", logFile)
    chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection=True,reference_preselection=False)
    timestampAndAppendTextToFile("Success Match photos done", logFile)
except Exception as e:
    timestampAndAppendTextToFile("PS_ERROR:" + str(e), logFile)

--- script.py end ---

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Segmentation fault matchPhotos
« Reply #1 on: December 14, 2017, 08:49:08 AM »
Hello zoocafe,

Can you also provide the processing log related to the failed operation from the script start? Also have you submitted the crash report?
Best regards,
Alexey Pasumansky,
Agisoft LLC

zoocafe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Segmentation fault matchPhotos
« Reply #2 on: December 14, 2017, 10:25:09 AM »
Hello Alexey,

I don't know how to submit the photoscan crashreport do you have any instructions? (that I searched for but didn't find)

Here is the log, I removed my own print to file log and changed it to print prefixed with "My print "

[zoocafe@VM_154_79_centos monkeyjob1]$ /home/zoocafe/photoscan-pro/photoscan.sh --platform offscreen -r script.py
SaveProject
saved project in 0.004647 sec
My print /home/zoocafe/pf-jobs/monkeyjob1
My print /home/zoocafe/pf-jobs/monkeyjob1/imgs
My print Number of photos:94
My print []
My print Success Add photos begin
AddPhotos
My print Success Add photos done
My print Success Match photos begin
MatchPhotos: accuracy = High, preselection = generic, keypoint limit = 40000, tiepoint limit = 4000, constrain features by mask = 0
/home/zoocafe/photoscan-pro/photoscan.sh: line 19: 27678 Segmentation fault      (core dumped) "$dirname/$appname" "$@"
[zoocafe@VM_154_79_centos monkeyjob1]$

--- script start ---
# This is run as Python 3.5 by Photoscan
import PhotoScan
import os
import json
import datetime

photoFolder = "imgs"
doc = PhotoScan.app.document
scriptdir = os.path.dirname(os.path.abspath(__file__))
logFile = os.path.join(scriptdir, "job.log")
doc.save(os.path.join(scriptdir, "psproject.psz"))
chunk = PhotoScan.app.document.addChunk()

# Get images in the folder
imgFolder = os.path.join(scriptdir, photoFolder)
print(scriptdir)
print(imgFolder)
includedExts = ['jpg', 'jpeg', 'png', 'tif']

file_names = []
for fn in os.listdir(imgFolder):
    fnlower = fn.lower()
    if any(fnlower.endswith(ext) for ext in includedExts):
        file_names.append(os.path.join(imgFolder,fn))

print("My print Number of photos:" + str(len(file_names)))

# print("My print Photos - start")
# for fn in file_names:
#     timestampAndAppendTextToFile(fn)
# print("My print Photos - end")

# Add processing server
GPUdevices = PhotoScan.app.enumGPUDevices()
prettyJson = json.dumps(GPUdevices, indent=2)
print("My print " + str(prettyJson))

try:
    print("My print Success Add photos begin")
    chunk.addPhotos(file_names)
    print("My print Success Add photos done")
    print("My print Success Match photos begin")
    chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, generic_preselection=True,reference_preselection=False)
    print("My print Success Match photos done")
except Exception as e:
    # traceback.print_exc() gives better error messager with line number
    # but when outputing to file only last line is shown
    print("My print PS_ERROR:" + str(e))

doc.save()

--- script end ---

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14818
    • View Profile
Re: Segmentation fault matchPhotos
« Reply #3 on: December 15, 2017, 03:46:57 PM »
Hello zoocafe,

Can you please sen in your script the following line prior to the image matching stage and let me know if the same issue occurs?
Code: [Select]
PhotoScan.app.gpu_mask = 0
Also does it happen for any image set or just for particular one?


You can try to check for the crash reports in the /tmp/ folder (unless any of the following environment variables were set up: TMPDIR, TMP, TEMP, TEMPDIR). There should be .dmp and .extra files.
Best regards,
Alexey Pasumansky,
Agisoft LLC