pogucam 0.1.7__py3-none-any.whl → 0.1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pogucam/buffers.py CHANGED
@@ -10,6 +10,9 @@ class FastAccumBuffer:
10
10
  self.shape = shape
11
11
  self._init_buffer()
12
12
  self._last_retrieved_idx = -1 #???
13
+ self.previous_sum_frames = None
14
+ #self._saturated_pixel_count = 0
15
+ self._saturated_pixel_count = np.zeros(3, dtype=int)
13
16
 
14
17
  def _init_buffer(self):
15
18
  self.cube = np.empty((self.max_frames, *self.shape), dtype=np.uint8)
@@ -17,6 +20,9 @@ class FastAccumBuffer:
17
20
  self.idx = 0
18
21
  self.count = 0
19
22
  self._last_retrieved_idx = -1 #???
23
+ self.previous_sum_frames = None
24
+ #self._saturated_pixel_count = 0
25
+ self._saturated_pixel_count = np.zeros(3, dtype=int)
20
26
 
21
27
  def add(self, img: np.ndarray, info: dict):
22
28
  """
@@ -45,14 +51,31 @@ class FastAccumBuffer:
45
51
  return False
46
52
  return self.idx != self._last_retrieved_idx # ???
47
53
 
54
+ def get_previous_sum_frames(self):
55
+ #print("i... prev buffers")
56
+ return self.previous_sum_frames
57
+
48
58
  def get_sum_frames(self):
49
59
  if self.count == 0:
60
+ self._saturated_pixel_count = 0
50
61
  return None
51
62
  #print("!... SUM")
52
63
  summed = np.sum(self.cube[:self.count].astype(np.uint16), axis=0)
64
+ saturated_mask = summed > 255#
65
+ #Count saturation per channel
66
+ self._saturated_pixel_count = np.array([
67
+ np.count_nonzero(saturated_mask[:, :, c]) for c in range(3)
68
+ ])
69
+ #self._saturated_pixel_count = np.count_nonzero(saturated_mask)
53
70
  np.clip(summed, 0, 255, out=summed)
54
71
  self._last_retrieved_idx = self.idx # ???
55
- return summed.astype(np.uint8)
72
+ #prev = self.previous_sum_frames
73
+ curr = summed.astype(np.uint8)
74
+ self.previous_sum_frames = curr
75
+ return curr# summed.astype(np.uint8)
76
+
77
+ def get_saturated_pixel_count(self):
78
+ return self._saturated_pixel_count
56
79
 
57
80
  def get_max_frames(self):
58
81
  return self.max_frames
@@ -467,8 +467,8 @@ class StreamWidget(QLabel):
467
467
  self.SAVED_NOW = False # for overtext info
468
468
  #
469
469
  self.xtended = False # 2x local
470
- self.flag_print = False # terminal \n
471
- self.flag_print_over = True # overtext
470
+ self.flag_print = False # terminal \n OR \r "P"
471
+ self.flag_print_over = True # overtext "S-P"
472
472
  self.flag_redcross = False
473
473
  self.error = False
474
474
  self.zoomme = 1
@@ -508,8 +508,8 @@ class StreamWidget(QLabel):
508
508
  #self.accum_buffer_size = 0 #
509
509
  #self.accum_count = 0 # actual number of img in buff
510
510
  # -------------------------------------------------
511
- self.level2_buffer = None
512
- self.level2_buffer_max_size = 10
511
+ #self.level2_buffer = None
512
+ #self.level2_buffer_max_size = 10
513
513
 
514
514
  # --------------------------------- I put it at the end so that it knows all attributes
515
515
  self.update_image()
@@ -542,7 +542,7 @@ class StreamWidget(QLabel):
542
542
  post_response = requests.post(url=self.post_addr, data=data )
543
543
  else:
544
544
  # --------------------------------------------------------- JUST LOCAL DEVICE ----------------
545
- print("X... no remote IP defined - nothing sent", data)
545
+ #print("X... no remote IP defined - nothing sent", data)
546
546
  #--------------------------- ------------------------------------ACUUMULATE LOCALY
547
547
  if ('accumtxt' in data):
548
548
  val = int(data['accumtxt']) # SIZE OF THE BUFFER
@@ -693,7 +693,7 @@ class StreamWidget(QLabel):
693
693
  if action == "q": # quit
694
694
  self.zoomme = 1
695
695
  self.redcross = [0, 0]
696
- self.l_gamma = 1
696
+ self.l_gamma = 1 # local is 1
697
697
  self.l_rotate = 0
698
698
 
699
699
  self.r_integrate = 0
@@ -859,14 +859,18 @@ class StreamWidget(QLabel):
859
859
  # OVERTEXT
860
860
  # --------------------------------------------------------------------------------
861
861
 
862
- def overttext(self, blackbar=False):
862
+ def overtext(self, blackbar=False, image=None):
863
863
  """
864
864
  great font for small numbers
865
865
  """
866
866
  #
867
867
  #
868
868
  #
869
- if self.frame is None:
869
+ selfimg = image
870
+ if selfimg is None:
871
+ selfimg = self.img
872
+ # ---------------------------
873
+ if selfimg is None:
870
874
  return
871
875
  RXT = f"XT:{self.r_xtend}" # CC LU ... for remote ok
872
876
  ZOO = f"ZOO:{self.zoomme:3.1f}"
@@ -895,29 +899,30 @@ class StreamWidget(QLabel):
895
899
  #
896
900
  overtext = f"{self.frame_time} # {self.frame_num} # {self.l_frame_num:6d} # {RXT} . {ZOO} . {ROO} . {LGA} . {SAV} {FIT} . {BUF}. {LAPS}"
897
901
  #
898
- position = ( 0, self.frame.shape[0]-1 ) # 480 on x-axis
902
+ position = ( 0, selfimg.shape[0]-1 ) # 480 on x-axis
899
903
  #
900
904
 
901
905
  if blackbar:
902
- overlay = self.frame.copy()
906
+ overlay = selfimg.copy()
903
907
  if self.resolution == "1920x1080":
904
908
  shade_height = 20
905
909
  else:
906
910
  shade_height = 10
907
- height, width = self.frame.shape[:2]
911
+ height, width = selfimg.shape[:2]
908
912
  cv2.rectangle(overlay, (0, height - shade_height), (width, height), (0, 0, 0), -1)
909
913
  alpha = 0.5
910
914
  #alpha = 0.
911
- cv2.addWeighted(overlay, alpha, self.frame, 1 - alpha, 0, self.frame)
915
+ #cv2.addWeighted(overlay, alpha, self.frame, 1 - alpha, 0, self.frame)
916
+ cv2.addWeighted(overlay, alpha, selfimg, 1 - alpha, 0, selfimg)
912
917
  #
913
918
  font = "di"
914
919
  if self.resolution == "1920x1080":
915
920
  font = "di2"
916
- self.img = iprint(self.img, str(overtext), font=font, position=position,color_rgb=(0,255,0) )
921
+ selfimg = iprint(selfimg, str(overtext), font=font, position=position,color_rgb=(0,255,0) )
917
922
  if self.SAVED_NOW:
918
- position = ( self.frame.shape[1] - 20, self.frame.shape[0]-1 ) # 480 on x-axis
919
- self.img = iprint(self.img, f"SAVE", font=font, position=position,color_rgb=(0,0,255) ) # bgr
920
-
923
+ position = ( selfimg.shape[1] - 20, selfimg.shape[0]-1 ) # 480 on x-axis
924
+ selfimg = iprint(selfimg, f"SAVE", font=font, position=position,color_rgb=(0,0,255) ) # bgr
925
+ self.img = selfimg
921
926
  #self.img = iprint(self.img, str(overtext), font="p7", position=position,color_rgb=(0,255,0) )
922
927
 
923
928
 
@@ -1105,6 +1110,8 @@ class StreamWidget(QLabel):
1105
1110
  mycnt += 1
1106
1111
  fff = fname1.replace(".jpg", f"_{mycnt:03d}.jpg")
1107
1112
  print(fff)
1113
+ if self.flag_print_over:
1114
+ self.overtext(blackbar=True) # ---- after ACCUM ------------------ img should be tagged
1108
1115
  if self.saving_jpg:
1109
1116
  cv2.imwrite(fff, i, [int(cv2.IMWRITE_JPEG_QUALITY), 90])
1110
1117
  else:
@@ -1327,7 +1334,7 @@ class StreamWidget(QLabel):
1327
1334
  print("X.... Timeouted on URLOPEN", end="\n")
1328
1335
  if nopass:
1329
1336
  self.which_error = f"{self.which_error} / NOPASS" # no password file
1330
- print( f"{str(dt.datetime.now() )[:-4]}---", end="\r")
1337
+ print( f"{str(dt.datetime.now() )[:-4]}....", end="\r")
1331
1338
 
1332
1339
  return stream
1333
1340
 
@@ -1480,7 +1487,7 @@ class StreamWidget(QLabel):
1480
1487
  self.frame_time = self.l_frame_time.strftime("%H:%M:%S.%f")[:-4]
1481
1488
  if not ret:
1482
1489
  return False
1483
- print(f" --- {self.frame_time} ; resolution /{self.frame.shape}/ ---- ", end="")
1490
+ print(f" ... {self.frame_time} ; resolution /{self.frame.shape}/ .... ", end="")
1484
1491
 
1485
1492
  avg = self.frame # once per Nx it is AVG
1486
1493
  self.img = avg # normally frame. but sometimes avg == really averaged img!
@@ -1641,11 +1648,10 @@ class StreamWidget(QLabel):
1641
1648
 
1642
1649
 
1643
1650
  # Final transformations before SAVE, you save zoomed------------------TRANNS OR NOT TRANS
1651
+ # TRANS Before save
1644
1652
  if self.saving_transformed_image:
1645
1653
  self.img = self.final_transformations( self.img )
1646
- if self.flag_print_over:
1647
- self.overttext() #
1648
- self.SAVED_NOW = False # this is for overtext RED save
1654
+ #self.SAVED_NOW = False # this is for overtext RED save # maybe I dont need it
1649
1655
 
1650
1656
  # SAVING organization HERE
1651
1657
  # SAVING organization HERE
@@ -1654,9 +1660,9 @@ class StreamWidget(QLabel):
1654
1660
  # SAVING organization HERE
1655
1661
  # SAVING organization HERE
1656
1662
 
1657
- if self.level2_buffer is None:
1658
- self.level2_buffer = buffers.AccumBuffer(self.img)
1659
- self.level2_buffer.define_accum_buffer( self.level2_buffer_max_size ) # ???
1663
+ #if self.level2_buffer is None:
1664
+ # self.level2_buffer = buffers.AccumBuffer(self.img)
1665
+ # self.level2_buffer.define_accum_buffer( self.level2_buffer_max_size ) # ???
1660
1666
 
1661
1667
 
1662
1668
  # DEFINE BUFFER, if not yet / if overtext is before, i have blurred timemarks
@@ -1667,11 +1673,22 @@ class StreamWidget(QLabel):
1667
1673
 
1668
1674
  # showing or NOT the average image
1669
1675
  if self.l_show_accum and (len(self.FABuffer) > 1):# and (len(self.accum_buffer) > 1):
1670
- rimg = self.FABuffer.get_sum_frames()#_mean_accum_buffer()
1676
+ rimg = None
1677
+ if self.FABuffer.new_sum_available():
1678
+ rimg = self.FABuffer.get_sum_frames()#_mean_accum_buffer()
1679
+ #print("\n new", type(rimg))
1680
+ print(f"SATURATED: {self.FABuffer.get_saturated_pixel_count()}", end="")
1681
+ else:
1682
+ rimg = self.FABuffer.get_previous_sum_frames()#_mean_accum_buffer()
1683
+ #print("\n----pre", type(rimg))
1671
1684
  if rimg is not None:
1672
1685
  self.img = rimg
1673
- self.overttext(blackbar=True) # applies on img
1686
+ #### self.overtext(blackbar=True) # applies on img
1674
1687
 
1688
+ if self.saving_all: #
1689
+ self.SAVED_NOW = True
1690
+ if self.flag_print_over:
1691
+ self.overtext(blackbar=True) # ---- after ACCUM ------------------ img should be tagged
1675
1692
 
1676
1693
 
1677
1694
  # # -- LAPS 1s 10s 60s but also accumulated local frames
@@ -1701,7 +1718,7 @@ class StreamWidget(QLabel):
1701
1718
  # self.saving_laps_last_save = now
1702
1719
  # self.save_img( time_tag=self.frame_time , savingjpg=False) #
1703
1720
 
1704
- # ---- just save once ----------------- -------------------------------------------- ************ "s" ***********
1721
+ # ---- just save once -------------------- ************ "s" ***********
1705
1722
  if self.saving_once:
1706
1723
  # jpg and NO AVG
1707
1724
  if (len(self.FABuffer) < 2) and (not self.l_show_accum) and (not self.saving_fits_only):
@@ -1761,6 +1778,7 @@ class StreamWidget(QLabel):
1761
1778
  # ---- save ALL ----------------- -------------------------------------------- ************ "shift-s" ***********
1762
1779
  # ---- save ALL ----------------- -------------------------------------------- ************ "shift-s" ***********
1763
1780
  if self.saving_all: # --------------- Shift-S-------
1781
+
1764
1782
  # jpg and NO AVG
1765
1783
  if (len(self.FABuffer) < 2) and (not self.l_show_accum) and (not self.saving_fits_only):
1766
1784
  self.save_img( time_tag=self.frame_time, dumpbuffer=False, use_fits=False) # every frame, BURSTING JPGS!
@@ -1836,23 +1854,17 @@ class StreamWidget(QLabel):
1836
1854
  pass
1837
1855
 
1838
1856
 
1839
-
1840
-
1841
-
1842
-
1843
-
1844
-
1845
-
1846
-
1847
-
1857
+ if self.flag_print_over:
1858
+ ####self.overtext(blackbar=True)
1859
+ self.SAVED_NOW = False # this is for overtext RED save
1848
1860
 
1849
1861
 
1850
1862
  # ------------------------------------- -------------------- TRANNS OR NOT TRANS
1851
1863
  if not self.saving_transformed_image:
1852
1864
  self.img = self.final_transformations( self.img )
1853
1865
  if self.flag_print_over:
1854
- self.overttext()
1855
- self.SAVED_NOW = False # this is for overtext RED save
1866
+ self.overtext(blackbar=True)
1867
+ #self.SAVED_NOW = False # this is for overtext RED save
1856
1868
 
1857
1869
  #
1858
1870
  else:# --- NO IMAGE CREATED ------------------------------- ... make the image gray ...
@@ -1861,6 +1873,9 @@ class StreamWidget(QLabel):
1861
1873
  self.img = cv2.cvtColor(self.img, cv2.COLOR_BGR2GRAY)
1862
1874
  self.img = cv2.cvtColor(self.img, cv2.COLOR_GRAY2BGR) #I want to keep 3 channels
1863
1875
  self.use_frame(stripes=True)# img = self.frame
1876
+
1877
+
1878
+
1864
1879
  #=============================== --------------------- =================== UPDATE/SHOW
1865
1880
  #=============================== --------------------- =================== UPDATE/SHOW
1866
1881
  #=============================== --------------------- =================== UPDATE/SHOW
@@ -1970,9 +1985,11 @@ class StreamWidget(QLabel):
1970
1985
  if (key == Qt.Key.Key_P):
1971
1986
  if ( len(parts_set) == 0):
1972
1987
  self.flag_print = not self.flag_print
1988
+ print(f"i... termtext: {self.flag_print}")
1973
1989
  #print("i... flasg print ", self.flag_print)
1974
1990
  elif (parts_set == {'Shift'}):
1975
1991
  self.flag_print_over = not self.flag_print_over
1992
+ print(f"i... overtext: {self.flag_print_over}")
1976
1993
  elif (parts_set == {'Ctrl'}) :
1977
1994
  pass
1978
1995
  # ----------------------------------------------------------------- e expo
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pogucam
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: Add your description here
5
5
  Author-email: jaromrax <jaromrax@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -0,0 +1,9 @@
1
+ pogucam/__init__.py,sha256=Iij7VvXCrFPMtTia41mQ7LxFLaulf_fD5cb-AyjpUo0,53
2
+ pogucam/buffers.py,sha256=9nW9W8z3wjaLcfFrZqmsnsowxQOWXTweOuHVjwWWIn8,6368
3
+ pogucam/explore_u24_uni.py,sha256=e2qpEagex5vqauXhPyaKOvxQelUjNyGnBJypoZmlZTk,111220
4
+ pogucam/installation.md,sha256=8qspiLlYjEBx5CedRfBU7Mm0A2pz0lfAnaupZyBm5Eo,128
5
+ pogucam/text_write.py,sha256=hyRyA1M5z-pda963T-k0i8fvvAlv1p3YBTZtYNdOeoE,19304
6
+ pogucam-0.1.9.dist-info/METADATA,sha256=frJgje8YmVhg6yTv6Vh_SjoSy-k66L9ixETyFAY-xNs,466
7
+ pogucam-0.1.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ pogucam-0.1.9.dist-info/entry_points.txt,sha256=-97N0LsXIR8h0rJMzIMuNeNwuY8LvPYPTqnXsuAnVsM,63
9
+ pogucam-0.1.9.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- pogucam/__init__.py,sha256=Iij7VvXCrFPMtTia41mQ7LxFLaulf_fD5cb-AyjpUo0,53
2
- pogucam/buffers.py,sha256=DwEmQYej6CJ7KwXLhR_ulIC_tziQAKM2yFQoEXZ-ocA,5432
3
- pogucam/explore_u24_uni.py,sha256=BHsS7pAtJKMr7EqlcERF2_MaP6ZZ1Lyy1xs1EMGF8-c,109954
4
- pogucam/installation.md,sha256=8qspiLlYjEBx5CedRfBU7Mm0A2pz0lfAnaupZyBm5Eo,128
5
- pogucam/text_write.py,sha256=hyRyA1M5z-pda963T-k0i8fvvAlv1p3YBTZtYNdOeoE,19304
6
- pogucam-0.1.7.dist-info/METADATA,sha256=zTstNsYYV4-ctxOPP0aRm1RYxBbTkpuqvBAlN7c07ug,466
7
- pogucam-0.1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- pogucam-0.1.7.dist-info/entry_points.txt,sha256=-97N0LsXIR8h0rJMzIMuNeNwuY8LvPYPTqnXsuAnVsM,63
9
- pogucam-0.1.7.dist-info/RECORD,,