편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2022.12.30

    라즈베리파이에서 사진 캡쳐 후 저장하는 코드를 짰는데 넘버링을 하고 싶습니다.


    StartTime = time.time()
    LastTime = 0
    for i in range (1) :
     while True :
        #[Do if there is Data to Process.]
      Length = Serial_PC_Justin.inWaiting()
      if Length == 0:
    
       continue
      data = Serial_PC_Justin.read(Length)
      File_Justin = open("LogData%s.jpg"%i,"ab")
      File_Justin.write(data)
      File_Justin.close()
      TotalLength += Length
    
        #[Print Periodically.]
      TimePassed = time.time() - StartTime
      if TimePassed > LastTime + 1:
       print(f"Total Length: {TotalLength} bytes")
       print(f"Average Speed: {TotalLength / (1024 ** 2 * TimePassed)} MB/s")
    Serial_PC_Justin.close()   #[Close the Port.]
    

    사진을 LogData.jpg로 저장하는데 코드 돌릴때 마다 넘버링을 하고 싶습니다.

    예를 들면 LogData1.jpg,LogData2.jpg, ...

    지금은 계속 한파일에만 덮어쓰네요.

  • 프로필 tackyoung.shin@austek.co.kr님의 편집
    날짜2022.12.30

    라즈베리파이에서 사진 캡쳐 후 저장하는 코드를 짰는데 넘버링을 하고 싶습니다.


    StartTime = time.time() LastTime = 0 for i in range (1) : while True : #[Do if there is Data to Process.] Length = Serial_PC_Justin.inWaiting() if Length == 0:

    continue data = Serial_PC_Justin.read(Length) File_Justin = open("LogData%s.jpg"%i,"ab") File_Justin.write(data) File_Justin.close() TotalLength += Length

    #[Print Periodically.]
    

    TimePassed = time.time() - StartTime if TimePassed > LastTime + 1: print(f"Total Length: {TotalLength} bytes") print(f"Average Speed: {TotalLength / (1024 ** 2 * TimePassed)} MB/s") Serial_PC_Justin.close() #[Close the Port.]

    사진을 LogData.jpg로 저장하는데 코드 돌릴때 마다 넘버링을 하고 싶습니다.

    예를 들면 LogData1.jpg,LogData2.jpg.....

    지금은 계속 한파일에만 덮어쓰네요ㅠ