From 91b81b98bc6f4fb4e2c60a9979b19b83452105a0 Mon Sep 17 00:00:00 2001 From: Prohurtz <48768484+RedHawk989@users.noreply.github.com> Date: Mon, 23 Jan 2023 22:16:52 -0600 Subject: [PATCH] small tuning --- EyeTrackApp/camera_widget.py | 6 +- EyeTrackApp/eye_processor.py | 4 +- EyeTrackApp/haar_surround_feature.py | 8 +- EyeTrackApp/intensity_eye_open.py | 32 ++- EyeTrackApp/osc.py | 2 +- EyeTrackApp/test_list.txt | 308 +++++++++++++++++++++++++++ 6 files changed, 339 insertions(+), 21 deletions(-) create mode 100644 EyeTrackApp/test_list.txt diff --git a/EyeTrackApp/camera_widget.py b/EyeTrackApp/camera_widget.py index 7856c55..cf916f3 100644 --- a/EyeTrackApp/camera_widget.py +++ b/EyeTrackApp/camera_widget.py @@ -299,7 +299,7 @@ class CameraWidget: graph = window[self.gui_output_graph] graph.erase() - if eye_info.info_type != InformationOrigin.FAILURE and not eye_info.blink: + if eye_info.info_type != InformationOrigin.FAILURE: #and not eye_info.blink: graph.update(background_color="white") if not np.isnan(eye_info.x) and not np.isnan(eye_info.y): @@ -317,8 +317,8 @@ class CameraWidget: line_color="white", ) - elif eye_info.blink: - graph.update(background_color="#6f4ca1") + # elif eye_info.blink: + # graph.update(background_color="#6f4ca1") elif eye_info.info_type == InformationOrigin.FAILURE: graph.update(background_color="red") # Relay information to OSC diff --git a/EyeTrackApp/eye_processor.py b/EyeTrackApp/eye_processor.py index edf9bae..2a4439b 100644 --- a/EyeTrackApp/eye_processor.py +++ b/EyeTrackApp/eye_processor.py @@ -268,10 +268,10 @@ class EyeProcessor: # self.output_images_and_update(thresh, EyeInformation(InformationOrigin.HSRAC, 0, 0, 0, False)) def HSFM(self): cx, cy, frame = External_Run_HSF.HSFS(self) - eyeopen = intense(cx, cy, frame) #not sure if i want this run on every algo or on the system.. + eyeopen = intense(cx, cy, self.current_image_gray) #not sure if i want this run on every algo or on the system.. out_x, out_y = cal_osc(self, cx, cy) if cx == 0: - self.output_images_and_update(frame, EyeInformation(InformationOrigin.HSF, out_x, out_y, 0, True)) #update app + self.output_images_and_update(frame, EyeInformation(InformationOrigin.HSF, out_x, out_y, 0, eyeopen)) #update app else: self.output_images_and_update(frame, EyeInformation(InformationOrigin.HSF, out_x, out_y, 0, eyeopen)) diff --git a/EyeTrackApp/haar_surround_feature.py b/EyeTrackApp/haar_surround_feature.py index 944b4f9..bbbe36b 100644 --- a/EyeTrackApp/haar_surround_feature.py +++ b/EyeTrackApp/haar_surround_feature.py @@ -599,7 +599,7 @@ class CenterCorrection(object): center_x, center_y = orig_x, orig_y self.frame_mask.fill(0) - cv2.circle(self.frame_mask, center=(center_x, center_y), radius=int(self.radius * 2), color=255, thickness=-1) + # cv2.circle(self.frame_mask, center=(center_x, center_y), radius=int(self.radius * 2), color=255, thickness=-1) # bottleneck cv2.calcHist([gray_frame], [0], None, [256], [0, 256], hist=self.hist) @@ -803,9 +803,9 @@ class HSRAC_cls(object): lower_y = center_y - radius # Crop the image using the calculated bounds cropped_image = gray_frame[lower_y:upper_y, lower_x:upper_x] - if imshow_enable or save_video: - cv2.circle(frame, (orig_x, orig_y), 6, (0, 0, 255), -1) - cv2.circle(frame, (center_x, center_y), 3, (255, 0, 0), -1) + # if imshow_enable or save_video: + # cv2.circle(frame, (orig_x, orig_y), 6, (0, 0, 255), -1) + # cv2.circle(frame, (center_x, center_y), 3, (255, 0, 0), -1) # If you want to update response_max. it may be more cost-effective to rewrite response_list in the following way # https://stackoverflow.com/questions/42771110/fastest-way-to-left-cycle-a-numpy-array-like-pop-push-for-a-queue diff --git a/EyeTrackApp/intensity_eye_open.py b/EyeTrackApp/intensity_eye_open.py index b31fae3..31076b0 100644 --- a/EyeTrackApp/intensity_eye_open.py +++ b/EyeTrackApp/intensity_eye_open.py @@ -19,8 +19,15 @@ client = udp_client.SimpleUDPClient(OSCip, OSCport) fname = "test_list.txt" data = pd.read_csv(fname, sep=",") +fl = [] def intense(x, y, frame): + upper_x = x + 25 + lower_x = x - 25 + upper_y = y + 25 + lower_y = y - 25 + frame = frame[lower_y:upper_y, lower_x:upper_x] + xy = int(str(x) + str(y) + str(x+y)) intensity = np.sum(frame) #print(intensity) @@ -31,6 +38,13 @@ def intense(x, y, frame): if intensity < data.at[dfb, 'intensity']: #if current intensity value is less (more pupil), save that data.at[dfb, 'intensity'] = intensity # set value changed = True + print("var adjusted") + + else: + intensitya = data.at[dfb, 'intensity'] - 3 #if current intensity value is less (more pupil), save that + data.at[dfb, 'intensity'] = intensitya # set value + changed = True + # print("var inc", intensity, intensitya) except: # that value is not yet saved @@ -42,8 +56,12 @@ def intense(x, y, frame): if intensity > data.at[0, 'intensity']: #if current intensity value is more (less pupil), save that NOTE: we have the data.at[0, 'intensity'] = intensity # set value at 0 index changed = True - print("new max", intensity) + + else: + intensityd = data.at[0, 'intensity'] - 10 #continuously adjust closed intensity, will be set when user blink, used to allow eyes to close when lighting changes + data.at[0, 'intensity'] = intensityd # set value at 0 index + changed = True except: # there is no max intensity yet, create data.at[0, 'intensity'] = intensity # set value at 0 index @@ -56,8 +74,9 @@ def intense(x, y, frame): #eyeopen = (intensity - minp) / (maxp - minp) eyeopen = (intensity - maxp) / (minp - maxp) eyeopen = 1 - eyeopen + print(intensity, maxp, minp, x, y) # eyeopen = max(0.0, min(1.0, eyeopen)) - print(f"EYEOPEN: {eyeopen}") + # print(f"EYEOPEN: {eyeopen}") client.send_message("/avatar/parameters/RightEyeLidExpandedSqueeze", float(eyeopen)) # open r client.send_message("/avatar/parameters/LeftEyeLidExpandedSqueeze", float(eyeopen)) except: @@ -67,17 +86,8 @@ def intense(x, y, frame): if changed == True: data.to_csv(fname, encoding='utf-8', index=False) #save file since we made a change - #e = data.at[dfb,'intensity'] #find intensity with value - - #data.at[dfb, 'intensity'] = 4 # set value - - #data.to_csv(fname, encoding='utf-8', index=False) #save file - - - #data.loc[len(data.index)] = [xy, intensity] - return eyeopen #vid = cv2.VideoCapture("http://192.168.1.43:4747/video") diff --git a/EyeTrackApp/osc.py b/EyeTrackApp/osc.py index 3b403a0..93279be 100644 --- a/EyeTrackApp/osc.py +++ b/EyeTrackApp/osc.py @@ -44,7 +44,7 @@ class VRChatOSC: (eye_id, eye_info) = self.msg_queue.get(block=True, timeout=0.1) except: continue - +#eye_info.blink if not eye_info.blink: if self.config.tracker_single_eye == 1 or self.config.tracker_single_eye == 2: self.client.send_message("/avatar/parameters/LeftEyeX", eye_info.x) # only one eye is detected or there is an error. Send mirrored data to both eyes. diff --git a/EyeTrackApp/test_list.txt b/EyeTrackApp/test_list.txt new file mode 100644 index 0000000..578de9c --- /dev/null +++ b/EyeTrackApp/test_list.txt @@ -0,0 +1,308 @@ +xy,intensity +473582.0,357639.0 +473583.0,250971.0 +463582.0,259772.0 +463581.0,250001.0 +463481.0,262307.0 +473482.0,259063.0 +503485.0,253050.0 +513586.0,242916.0 +523486.0,245595.0 +523587.0,239752.0 +523588.0,235965.0 +533589.0,234207.0 +553792.0,227890.0 +573997.0,219112.0 +594099.0,211998.0 +6040100.0,97336.0 +6040101.0,204647.0 +6041101.0,206041.0 +553692.0,222899.0 +533689.0,234080.0 +523689.0,235235.0 +533588.0,234591.0 +513587.0,240166.0 +503586.0,242147.0 +483584.0,248543.0 +453681.0,252077.0 +453581.0,252706.0 +453580.0,238681.0 +443580.0,251563.0 +0.0,-282.0 +483583.0,246862.0 +513687.0,239926.0 +513486.0,244214.0 +543691.0,229066.0 +553691.0,224848.0 +563793.0,222710.0 +563693.0,221737.0 +563692.0,221532.0 +543589.0,233991.0 +523688.0,237634.0 +513688.0,240610.0 +503686.0,241587.0 +493686.0,243116.0 +483685.0,241468.0 +483785.0,242252.0 +473784.0,243209.0 +463784.0,244225.0 +453884.0,245899.0 +453883.0,245353.0 +443883.0,244192.0 +443882.0,245493.0 +433982.0,246043.0 +433882.0,246397.0 +423982.0,247620.0 +423981.0,248308.0 +433881.0,250237.0 +443782.0,255290.0 +453782.0,251893.0 +463783.0,247845.0 +443781.0,256185.0 +453783.0,252276.0 +463682.0,257657.0 +473683.0,248249.0 +473684.0,254666.0 +483684.0,253290.0 +493685.0,253745.0 +553590.0,160147.0 +563591.0,228955.0 +573592.0,227065.0 +583594.0,229045.0 +573593.0,229591.0 +563592.0,230609.0 +553490.0,235088.0 +543489.0,235599.0 +503585.0,235551.0 +493585.0,252256.0 +463683.0,249050.0 +453682.0,256510.0 +433780.0,257233.0 +423780.0,257321.0 +433781.0,254818.0 +423881.0,255737.0 +463884.0,245749.0 +473785.0,242568.0 +483786.0,249030.0 +493786.0,247564.0 +503787.0,244608.0 +543690.0,234709.0 +543590.0,233992.0 +553591.0,232013.0 +583593.0,228357.0 +583493.0,226658.0 +593594.0,228134.0 +583492.0,227921.0 +573391.0,231334.0 +573390.0,231444.0 +563390.0,234623.0 +563389.0,234593.0 +553388.0,237340.0 +543387.0,235194.0 +533386.0,239102.0 +523386.0,241225.0 +523385.0,241552.0 +513384.0,250384.0 +503383.0,253299.0 +493383.0,254572.0 +483382.0,258460.0 +473481.0,259955.0 +463480.0,258556.0 +453480.0,259863.0 +443680.0,261992.0 +433579.0,261555.0 +433679.0,259909.0 +433680.0,256797.0 +423880.0,258517.0 +424082.0,253054.0 +434083.0,250342.0 +434084.0,248101.0 +444084.0,246720.0 +444085.0,250595.0 +444488.0,265335.0 +464995.0,289119.0 +4954104.0,295429.0 +4953103.0,294742.0 +454893.0,283001.0 +464591.0,271508.0 +474491.0,264746.0 +484290.0,258544.0 +484190.0,255352.0 +484089.0,251344.0 +494089.0,245657.0 +493989.0,232298.0 +503990.0,230283.0 +513890.0,238264.0 +513990.0,226967.0 +523890.0,235722.0 +523891.0,234865.0 +533891.0,233355.0 +533791.0,232810.0 +543791.0,232428.0 +523790.0,237078.0 +513789.0,242689.0 +513788.0,242871.0 +533488.0,237010.0 +533487.0,238427.0 +533387.0,237412.0 +513385.0,244320.0 +503384.0,248585.0 +493382.0,255212.0 +483381.0,254841.0 +473381.0,258108.0 +473380.0,257087.0 +453479.0,260130.0 +443579.0,261332.0 +473885.0,242285.0 +483886.0,240662.0 +483887.0,238495.0 +493887.0,236504.0 +493988.0,234020.0 +503989.0,232407.0 +513991.0,225947.0 +523991.0,224778.0 +504090.0,229604.0 +494090.0,233456.0 +483988.0,236861.0 +484088.0,237088.0 +483987.0,239272.0 +473987.0,238618.0 +473986.0,240348.0 +473886.0,241339.0 +493484.0,249358.0 +503484.0,247653.0 +543388.0,233512.0 +523284.0,256409.0 +543084.0,269285.0 +542983.0,280529.0 +542883.0,291685.0 +9738135.0,213939.0 +9638134.0,219657.0 +9738136.0,213451.0 +9839137.0,204007.0 +9839138.0,204217.0 +9440134.0,228059.0 +9241134.0,240587.0 +9141133.0,246331.0 +9539134.0,224047.0 +9739136.0,211537.0 +533084.0,279261.0 +533184.0,262679.0 +523285.0,255018.0 +532983.0,274461.0 +532781.0,302302.0 +9637133.0,222471.0 +9537132.0,229626.0 +9737135.0,215710.0 +9637134.0,221660.0 +9537133.0,229847.0 +9737134.0,215498.0 +523184.0,257570.0 +494291.0,298100.0 +5250102.0,307350.0 +514192.0,302543.0 +523487.0,269115.0 +493483.0,259705.0 +483482.0,264756.0 +483483.0,263669.0 +542782.0,288667.0 +543185.0,253212.0 +533185.0,257473.0 +533285.0,252283.0 +513284.0,256989.0 +8552138.0,258478.0 +5151103.0,312095.0 +514799.0,313296.0 +544296.0,302653.0 +533892.0,289151.0 +543488.0,256997.0 +514395.0,299664.0 +5351104.0,304022.0 +485098.0,307963.0 +514294.0,304829.0 +503687.0,251585.0 +503788.0,248328.0 +493888.0,246838.0 +464086.0,252127.0 +454085.0,239326.0 +443984.0,255446.0 +433983.0,256770.0 +443681.0,264741.0 +543286.0,253677.0 +543186.0,251910.0 +513283.0,258668.0 +503283.0,259877.0 +493282.0,264590.0 +483281.0,266513.0 +463380.0,269924.0 +483280.0,270615.0 +493079.0,271830.0 +492979.0,271781.0 +492978.0,272371.0 +493080.0,271169.0 +513082.0,261750.0 +513183.0,260039.0 +523083.0,271107.0 +532881.0,278287.0 +9635131.0,228473.0 +9535130.0,233599.0 +9535131.0,233232.0 +9436130.0,236829.0 +9736134.0,218341.0 +8850138.0,238086.0 +5249101.0,310885.0 +494695.0,315451.0 +533286.0,252608.0 +504394.0,302886.0 +504293.0,306282.0 +522982.0,272159.0 +9635132.0,229019.0 +9736133.0,218560.0 +523082.0,298688.0 +493181.0,280463.0 +504696.0,307991.0 +9149141.0,221327.0 +504091.0,304619.0 +493787.0,253151.0 +513182.0,261244.0 +513081.0,263879.0 +503181.0,264893.0 +493584.0,256296.0 +503182.0,264151.0 +6050110.0,143710.0 +554095.0,79411.0 +10050150.0,83752.0 +6045105.0,146315.0 +6540105.0,48067.0 +6535100.0,137496.0 +653095.0,86445.0 +7535110.0,153158.0 +4040.0,-6.0 +7030100.0,163605.0 +652085.0,0.0 +65065.0,-15.0 +6565130.0,235622.0 +6555120.0,292006.0 +6560125.0,234630.0 +5560115.0,372229.0 +5055105.0,272624.0 +5550105.0,241914.0 +5050100.0,318630.0 +5555110.0,252782.0 +6055115.0,217787.0 +5545100.0,225673.0 +504595.0,236617.0 +405090.0,262150.0 +455095.0,272500.0 +454590.0,267193.0 +405595.0,267416.0 +404080.0,215254.0 +4060100.0,273388.0 +603595.0,269172.0 +404585.0,257809.0 +403575.0,253865.0 +403070.0,264744.0 +453075.0,265099.0 +503080.0,261448.0 +6550115.0,158537.0 +4065105.0,67964.0