Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - magic

Pages: 1 [2] 3 4
16
Python and Java API / Re: Find cameras by time
« on: May 18, 2018, 09:54:11 AM »
I've trying to modify it and still nothing  :-\ , did somebody can check it please have a lot images to do , and Im stuck with and have to finish it today  :-\, Alexey are You there my god of python ??
Code: [Select]
import os, PhotoScan
import datetime
chunk = PhotoScan.app.document.chunk
time_table = list()
for camera in chunk.cameras:
    time = camera.photo.meta['Exif/DateTimeOriginal'].split(" ")[1][:-3].replace(":", ".")
    time = float(time)
    time = time // 1 + (time  - time // 1) * 100 / 60
    time_table.append(time)

    time_table.sort()
    limits = (time_table[0], time_table[-1])
    #limits = time[0], time[-1]
    interval = 08.02
    interval1 = 08.03
    start = limits[0]
    while True:
        finish = start + interval
        time = float(camera.photo.meta['Exif/DateTimeOriginal'].split(" ")[1][:-3].replace(":", "."))
        time = time // 1 + (time  - time // 1) * 100 / 60

        if start <= time < start + interval1:
            camera.selected = True
            empty = False

    start += interval

17
Python and Java API / Re: Find cameras by time
« on: May 17, 2018, 03:31:56 PM »
I've added it and still have an error
Code: [Select]
import os, PhotoScan

chunk = PhotoScan.app.document.chunk
time_table = list()
for camera in chunk.cameras:
    time = float(camera.photo.meta['Exif/DateTimeOriginal'].split(" ")[1][:-3].replace(":", "."))
    time = time // 1 + (time  - time // 1) * 100 / 60
    time_table.append(time)
    #time_table.sort()
    print(time_table)
time_table.sort()
limits = (time_table[0], time_table[-1])
interval = 08.03
interval1 = 08.05
start = limits[0]
    #interval2 = interval + interval1
    #time = time // 1 + time  - time // 1
while True:
    finish = start + interval1
    if start <= time < start + interval1:
        camera.selected = True
Someone know what Im doing wrong
It doesn't work, help please  :-[ :-[

18
Python and Java API / Find and select cameras by time in chunk
« on: May 17, 2018, 02:55:28 PM »
Hi team
I have some script and I can see time all my cameras in chunk(ex 10.59,10.59,10.59,11.00,11.00 etc) , what I want to do is to find and select only the images with specific time for example , cameras been taken at 10am to 4pm , and I want only work with cameras with been taken at 1am05 to 1am25 , and selected them how we can do it it is possible, and I have some error message with split...
AttributeError: 'NoneType' object has no attribute 'split'
2018-05-17 14:08:56 Error: 'NoneType' object has no attribute 'split'
Code: [Select]
import os, PhotoScan

chunk = PhotoScan.app.document.chunk
time_table = list()
for camera in chunk.cameras:
    time = camera.photo.meta['Exif/DateTimeOriginal'].split(" ")[1][:-3].replace(":", ".")
    time_table.append(time)
    time_table.sort()
time_table.sort()
print(time_table)
Thaths what I have for now , any body can help please???

19
Python and Java API / Re: Remove duplicate images
« on: January 05, 2018, 02:40:10 PM »
Hi Alexey
Works better now
Thanks a lot

20
Python and Java API / Re: Remove duplicate images
« on: January 03, 2018, 01:06:07 PM »
Did You can check it Alexey please still have some error at the end of my script
Code: [Select]
import PhotoScan, os

chunk = PhotoScan.app.document.chunk

photos = set()

for photos in list(chunk.cameras):
    print(photos)  #over here i print all my list photos ,think so its ok
    if camera.photo.path in photos:  #<<<<I'v got an error- argument is not iterable
 
        chunk.remove(photos)

    else:
        photos.add(camera.photo)
Why before that worked and now error coming out , what I do wrong Alexey

21
Python and Java API / Re: Remove duplicate images
« on: January 02, 2018, 02:43:47 PM »
Hi Alexey
I cant figured this out Alexey, have to make a list and then go to those list and deleting images in ?
Code: [Select]
import PhotoScan, os

chunk = PhotoScan.app.document.chunk

for camera in chunk.cameras:
    li = ()
    for camera in li:
         chunk.remove(photos)
else:
   
    photos.add(camera.photo.path)


22
Python and Java API / Re: Remove duplicate images
« on: December 29, 2017, 05:08:24 PM »
Ok thx will check it next Tuesday,
Have a fun and happy new year

23
Python and Java API / Remove duplicate images
« on: December 29, 2017, 02:38:56 PM »
Hi Alexey
Few days ago iv tried this script to remove all duplicate images from my workspace with works well with low number of images :
Code: [Select]
import PhotoScan, os

chunk = PhotoScan.app.document.chunk
print("start")
photos = set()
for camera in list(chunk.cameras):
      if camera.photo.path in photos:
             chunk.remove(camera)
      else:
             photos.add(camera.photo.path)

Problem starts when after few actions like merge etc and several chunks from 60k cameras I go up to 300k(all doubles) and when I tried to started this script its was like turning about 4 hours  without any results , then iv breaked it , takes to long time, did it is possible to optimize this script and get it run faster ?? Iv tried few others(similar pythons scripts) method but no one of them works with PS. Did we vgot some solution Alexey or we cant do it together with PS??

24
Can You check it Alexey please still cant solve it
Code: [Select]
doc = PhotoScan.app.document
chunk = doc.addChunk()

# Ajout de photos -add photos 1st chunk
path_photos = PhotoScan.app.getExistingDirectory("main folder:")
image_list = os.listdir(path_photos)
photo_list = list()
for root, dirs, files in os.walk(path_photos):
    new_group = chunk.addCameraGroup()
    for photo in image_list:
        if photo.rsplit(".",1)[1].lower() in  ["jpg", "jpeg", "tif", "tiff"]:
            photo_list.append("/".join([path_photos, photo]))
        chunk.addPhotos(photo_list)
        print("- Photos ajoutées")
           
        for camera in list(chunk.cameras):
            camera.group = new_group

25
Python and Java API / Loading images from subdirectory to cameras groupes
« on: December 19, 2017, 02:50:48 PM »
Hi All ,

I have a  main directory with a lot of sub-directories and I would like to load them all  to my PhotoScan chunk with a python script, each sub-directory to new camera group ,   
Iv got some script with create camera group but i have no Idea how to modify it to create new camera group for next sub-dir etc ...
Code: [Select]
doc = PhotoScan.app.document
chunk = doc.addChunk()
new_group = chunk.addCameraGroup()

# Ajout de photos -add photos 1st chunk
path_photos = PhotoScan.app.getExistingDirectory("main folder:")
image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
    if photo.rsplit(".",1)[1].lower() in  ["jpg", "jpeg", "tif", "tiff"]:
        photo_list.append("/".join([path_photos, photo]))
chunk.addPhotos(photo_list)
print("- Photos ajoutées")

for camera in list(chunk.cameras):
camera.group = new_group
Did anybody can help pls ?

26
Python and Java API / Re: Add photos to the chunk
« on: December 19, 2017, 02:06:34 PM »
Anybody here ??

27
Python and Java API / Re: Add photos to the chunk
« on: December 19, 2017, 10:49:40 AM »
Hi Alexey
Iv got some small problem again , now I try to load the cameras to my chunk and the cameras are in main directory and I have sub-folders inside it is possible to get the cameras and load them to new cameras group for each sub-folder ??
Iv tried thats but dsnt work as i would to

Code: [Select]
doc = PhotoScan.app.document
chunk = doc.addChunk()
new_group = chunk.addCameraGroup()

# Ajout de photos -add photos 1st chunk
path_photos = PhotoScan.app.getExistingDirectory("main folder:")
image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
    if photo.rsplit(".",1)[1].lower() in  ["jpg", "jpeg", "tif", "tiff"]:
        photo_list.append("/".join([path_photos, photo]))
chunk.addPhotos(photo_list)
print("- Photos ajoutées")

for camera in list(chunk.cameras):
camera.group = new_group
Its better but still dsnt work
Any suggestion Alexey ??

28
Python and Java API / Re: Add photos to the chunk
« on: December 18, 2017, 05:25:39 PM »
Hi Alexey
Iv got some small problem again , now I try to load the cameras to my chunk and the cameras are in main directory and I have sub-folders inside it is possible to get the cameras and load them to new cameras group for each sub-folder ??
Iv tried thats but dsnt work as i would to

doc = PhotoScan.app.document
chunk = doc.addChunk()
chunk.label = "New Chunk"

# Ajout de photos -add photos 1st chunk
path_photos = PhotoScan.app.getExistingDirectory("main folder:")
image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
    if photo.rsplit(".",1)[1].lower() in  ["jpg", "jpeg", "tif", "tiff"]:
           photo_list.append("/".join([path_photos, photo]))
chunk.addPhotos(photo_list)
print("- Photos ajoutées")

group = chunk.addCameraGroup()
for img in image_list:
    camera = chunk.cameras[0]
    group = chunk.addCameraGroup()
    camera.group = group
    group.type = PhotoScan.CameraGroup.Station

Any suggestion Alexey ??

29
Python and Java API / Re: Export Undistort cameras to new folder
« on: December 13, 2017, 12:34:12 PM »
I figured it out

Code: [Select]
import PhotoScan
import os, sys
os.mkdir("F:\\Ps\\res_photo\\undisorted_done")
os.mkdir("F:\\Ps\\res_photo\\undisorted_done\\LT")
os.mkdir("F:\\Ps\\res_photo\\undisorted_done\\HD") #creation new directory 1st-undisorted_done, 2nd HD
my_dir = ("F:\\Ps\\res_photo\\undisorted_done\\HD")
noveaux_dir = "F:\\Ps\\res_photo\\undisorted_done\\LT"
chunk = doc.chunk #active chunk

for camera in chunk.cameras:
    myImage = camera.photo.image()
    calibration = camera.sensor.calibration
    newImage = myImage.undistort(calibration, True, True)
    newName = os.path.split(camera.photo.path)[-1]
    newName_undi = os.path.splitext(newName)[0]
    save_img = os.path.join(my_dir,os.path.basename(newName_undi) + '_.jpg')
    newImage.save(save_img)
    img = camera.photo.image()
    img = img.resize(256, 170)
    newName1 = os.path.split(camera.photo.path)[-1]
    newName_undi1 = os.path.splitext(newName1)[0]
    save_fname = os.path.join(noveaux_dir, os.path.basename(newName_undi1)+'_res.jpg')
    img.save(save_fname)

Action : create new directories , Undistorted cameras and resize undistorted cameras :-)

30
Python and Java API / Re: Export Undistort cameras to new folder
« on: December 13, 2017, 11:47:16 AM »
Hi Alexey,
I have a small problem again Alexey, my script for undistorted cameras works well, and now iv added second one to Resize
and save in new directory undistorted cameras and PhotoScan crashed , and do this each time when i put my script to the console.
My new script works well in python console but dsnt works in PhotoScan, could You check it for me please why , whats wrong with , did is a PhotoScan python library problem ??
Iv added Pilllow module to main python PhotoScan Library.

Code: [Select]
import os, sys
import PhotoScan
from PIL import Image
from os import listdir
from os.path import isfile, join
from PySide2 import QtCore, QtGui, QtWidgets

os.mkdir("F:\\Ps\\res_photo\\undisorted_done")
os.mkdir("F:\\Ps\\res_photo\\undisorted_done\\HD") #creation new directory 1st-undisorted_done, 2nd HD
my_dir = ("F:\\Ps\\res_photo\\undisorted_done\\HD")
chunk = doc.chunk #active chunk

for camera in chunk.cameras:
     #camera = chunk.cameras[0]
    currentCameraImage = camera.photo.image()
    calibration = camera.sensor.calibration
    undistortedCameraImage = currentCameraImage.undistort(calibration, True, True)
    undistortedFullImageName = os.path.split(camera.photo.path)[-1]
    undistortedImageName = os.path.splitext(undistortedFullImageName)[0]
    save_img = os.path.join(my_dir,os.path.basename(undistortedImageName) + '_.jpg')
    undistortedCameraImage.save(save_img)

mypath = "F:\\Ps\\res_photo\\undisorted_done\\HD"
os.mkdir("F:\\Ps\\res_photo\\undisorted_done\\LT")
noveaux_dir = "F:\\Ps\\res_photo\\undisorted_done\\LT"
dirs = os.listdir( mypath )
basewidth = 256

for im in dirs:
    img = Image.open(join(mypath, im))
    src_fname, ext = os.path.splitext(mypath + im)
    wpercent = (basewidth / float(img.size[0]))
    hsize = int((float(img.size[1]) * float(wpercent)))
    img = img.resize((basewidth, hsize), Image.ANTIALIAS)
    save_fname = os.path.join(noveaux_dir, os.path.basename(src_fname)+'_res.jpg')
    img.save(save_fname)

Fast explication: my script work till last save ( im2.save(save_fname)), iv used print to debug it and he do all actions , but dont like SAVE mode, whats i can do Alexey ????

Pages: 1 [2] 3 4