Filtering returned values variable with majority votesAre static class variables possible in Python?How do I sort a list of dictionaries by a value of the dictionary?How do I return multiple values from a function?Using global variables in a functionHow do I sort a dictionary by value?How do I pass a variable by reference?Checking whether a variable is an integer or notHow to access environment variable values?Classifiers confidence in opencv face detectorSelect rows from a DataFrame based on values in a column in pandas

If a non-friend comes across my Steam Wishlist, how easily can he gift me one of the games?

Why do players in the past play much longer tournaments than today's top players?

Is "I do not want you to go nowhere" a case of "DOUBLE-NEGATIVES" as claimed by Grammarly?

Referring to different instances of the same character in time travel

What's the minimum number of sensors for a hobby GPS waypoint-following UAV?

Reverse dots and boxes, swastika edition

How can I effectively communicate to recruiters that a phone call is not possible?

Why isn't there research to build a standard lunar, or Martian mobility platform?

How can a dictatorship government be beneficial to a dictator in a post-scarcity society?

Are randomly-generated passwords starting with "a" less secure?

Changing trains in the Netherlands

The monorail explodes before I can get on it

Why does the U.S. tolerate foreign influence from Saudi Arabia and Israel on its domestic policies while not tolerating that from China or Russia?

How to loop for 3 times in bash script when docker push fails?

Credit score and financing new car

Has anyone in space seen or photographed a simple laser pointer from Earth?

RPI3B+: What are the four components below the HDMI connector called?

Matchmaker, Matchmaker, make me a match

Professor falsely accusing me of cheating in a class he does not teach, 2 months after end of the class. What precautions should I take?

How to convert a file with several spaces into a tab-delimited file?

What's the point of having a RAID 1 configuration over incremental backups to a secondary drive?

Would dual wielding daggers be a viable choice for a covert bodyguard?

Generating random numbers that keep a minimum distance

Managing and organizing the massively increased number of classes after switching to SOLID?



Filtering returned values variable with majority votes


Are static class variables possible in Python?How do I sort a list of dictionaries by a value of the dictionary?How do I return multiple values from a function?Using global variables in a functionHow do I sort a dictionary by value?How do I pass a variable by reference?Checking whether a variable is an integer or notHow to access environment variable values?Classifiers confidence in opencv face detectorSelect rows from a DataFrame based on values in a column in pandas






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Good day, I am new to python and currently I am trying to work with my object detection assignment. What I am currently working with is to do filtering and do counting for objects that have been detected. For e.g , I have 3 return variables such as boxes (bounding boxes that appeared, to do counting), classId and confidence (to determine the object classes and its probability) with



print (len(boxes),classId,confidence)


and i got values like this (1 sec for 50+ values)



(1, 'Sunbear', 0.91407496)

(1, 'Sunbear', 0.93277943)

(1, 'Sunbear', 0.8578589)

(2, 'Sunbear', 0.29979056)

(1, 'Sunbear', 0.8787856)

(2, 'Sunbear', 0.32679325)

(1, 'Sunbear', 0.79356045)


Here is what i wanted to do:



To take the majority values that appeared for every 10 ( or more) returned values for boxes, classId and confidence (average value for this), to eliminate random fluctuation. Here are part of my codes,



 classIds = []
confidences = []
boxes = []
for out in outs:
for detection in out:
scores = detection[5:]
classId = np.argmax(scores)
confidence = scores[classId]
if confidence > confThreshold:
center_x = int(detection[0] * frameWidth)
center_y = int(detection[1] * frameHeight)
width = int(detection[2] * frameWidth)
height = int(detection[3] * frameHeight)
left = int(center_x - width / 2)
top = int(center_y - height / 2)
classIds.append(classId)
confidences.append(float(confidence))
boxes.append([left, top, width, height])
if classId ==0:
classId = 'Asian_elephant'
elif classId ==1:
classId = 'Sunbear'
elif classId ==2:
classId = 'Tapir'
#print ()
#logging.debug('%s %s %s', len(boxes), confidence,classId)
#logging.debug(boxes)
print ((len(boxes),classId,confidence))


Here is what I am trying to do:



If classId of 'Sunbear' appeared 5 times or more continuously , it will print the returned values and the count will reset back to 0 or else it will keep resetting to zero till the condition is met.



 count=0
while classId=='Sunbear':
count+=1
if count>=5:
print ((len(boxes),classId,confidence))
break


but somehow the returned values are the same in or outside the loop. Is this the right way of doing this, or there is some more efficient ways to do it. Please bear with me, I am new to programming, thanks in advance.










share|improve this question
























  • what's the result that you got?

    – gameon67
    Mar 26 at 4:19











  • @gameon67 something like this (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.8578589) (1, 'Sunbear', 0.8578589) (2, 'Sunbear', 0.29979056) (2, 'Sunbear', 0.29979056) (1, 'Sunbear', 0.8787856) (1, 'Sunbear', 0.8787856) (2, 'Sunbear', 0.32679325) (2, 'Sunbear', 0.32679325) (1, 'Sunbear', 0.79356045) (1, 'Sunbear', 0.79356045) as you can see both inside and outside (loop) values are the same

    – shiji
    Mar 26 at 7:26


















0















Good day, I am new to python and currently I am trying to work with my object detection assignment. What I am currently working with is to do filtering and do counting for objects that have been detected. For e.g , I have 3 return variables such as boxes (bounding boxes that appeared, to do counting), classId and confidence (to determine the object classes and its probability) with



print (len(boxes),classId,confidence)


and i got values like this (1 sec for 50+ values)



(1, 'Sunbear', 0.91407496)

(1, 'Sunbear', 0.93277943)

(1, 'Sunbear', 0.8578589)

(2, 'Sunbear', 0.29979056)

(1, 'Sunbear', 0.8787856)

(2, 'Sunbear', 0.32679325)

(1, 'Sunbear', 0.79356045)


Here is what i wanted to do:



To take the majority values that appeared for every 10 ( or more) returned values for boxes, classId and confidence (average value for this), to eliminate random fluctuation. Here are part of my codes,



 classIds = []
confidences = []
boxes = []
for out in outs:
for detection in out:
scores = detection[5:]
classId = np.argmax(scores)
confidence = scores[classId]
if confidence > confThreshold:
center_x = int(detection[0] * frameWidth)
center_y = int(detection[1] * frameHeight)
width = int(detection[2] * frameWidth)
height = int(detection[3] * frameHeight)
left = int(center_x - width / 2)
top = int(center_y - height / 2)
classIds.append(classId)
confidences.append(float(confidence))
boxes.append([left, top, width, height])
if classId ==0:
classId = 'Asian_elephant'
elif classId ==1:
classId = 'Sunbear'
elif classId ==2:
classId = 'Tapir'
#print ()
#logging.debug('%s %s %s', len(boxes), confidence,classId)
#logging.debug(boxes)
print ((len(boxes),classId,confidence))


Here is what I am trying to do:



If classId of 'Sunbear' appeared 5 times or more continuously , it will print the returned values and the count will reset back to 0 or else it will keep resetting to zero till the condition is met.



 count=0
while classId=='Sunbear':
count+=1
if count>=5:
print ((len(boxes),classId,confidence))
break


but somehow the returned values are the same in or outside the loop. Is this the right way of doing this, or there is some more efficient ways to do it. Please bear with me, I am new to programming, thanks in advance.










share|improve this question
























  • what's the result that you got?

    – gameon67
    Mar 26 at 4:19











  • @gameon67 something like this (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.8578589) (1, 'Sunbear', 0.8578589) (2, 'Sunbear', 0.29979056) (2, 'Sunbear', 0.29979056) (1, 'Sunbear', 0.8787856) (1, 'Sunbear', 0.8787856) (2, 'Sunbear', 0.32679325) (2, 'Sunbear', 0.32679325) (1, 'Sunbear', 0.79356045) (1, 'Sunbear', 0.79356045) as you can see both inside and outside (loop) values are the same

    – shiji
    Mar 26 at 7:26














0












0








0








Good day, I am new to python and currently I am trying to work with my object detection assignment. What I am currently working with is to do filtering and do counting for objects that have been detected. For e.g , I have 3 return variables such as boxes (bounding boxes that appeared, to do counting), classId and confidence (to determine the object classes and its probability) with



print (len(boxes),classId,confidence)


and i got values like this (1 sec for 50+ values)



(1, 'Sunbear', 0.91407496)

(1, 'Sunbear', 0.93277943)

(1, 'Sunbear', 0.8578589)

(2, 'Sunbear', 0.29979056)

(1, 'Sunbear', 0.8787856)

(2, 'Sunbear', 0.32679325)

(1, 'Sunbear', 0.79356045)


Here is what i wanted to do:



To take the majority values that appeared for every 10 ( or more) returned values for boxes, classId and confidence (average value for this), to eliminate random fluctuation. Here are part of my codes,



 classIds = []
confidences = []
boxes = []
for out in outs:
for detection in out:
scores = detection[5:]
classId = np.argmax(scores)
confidence = scores[classId]
if confidence > confThreshold:
center_x = int(detection[0] * frameWidth)
center_y = int(detection[1] * frameHeight)
width = int(detection[2] * frameWidth)
height = int(detection[3] * frameHeight)
left = int(center_x - width / 2)
top = int(center_y - height / 2)
classIds.append(classId)
confidences.append(float(confidence))
boxes.append([left, top, width, height])
if classId ==0:
classId = 'Asian_elephant'
elif classId ==1:
classId = 'Sunbear'
elif classId ==2:
classId = 'Tapir'
#print ()
#logging.debug('%s %s %s', len(boxes), confidence,classId)
#logging.debug(boxes)
print ((len(boxes),classId,confidence))


Here is what I am trying to do:



If classId of 'Sunbear' appeared 5 times or more continuously , it will print the returned values and the count will reset back to 0 or else it will keep resetting to zero till the condition is met.



 count=0
while classId=='Sunbear':
count+=1
if count>=5:
print ((len(boxes),classId,confidence))
break


but somehow the returned values are the same in or outside the loop. Is this the right way of doing this, or there is some more efficient ways to do it. Please bear with me, I am new to programming, thanks in advance.










share|improve this question
















Good day, I am new to python and currently I am trying to work with my object detection assignment. What I am currently working with is to do filtering and do counting for objects that have been detected. For e.g , I have 3 return variables such as boxes (bounding boxes that appeared, to do counting), classId and confidence (to determine the object classes and its probability) with



print (len(boxes),classId,confidence)


and i got values like this (1 sec for 50+ values)



(1, 'Sunbear', 0.91407496)

(1, 'Sunbear', 0.93277943)

(1, 'Sunbear', 0.8578589)

(2, 'Sunbear', 0.29979056)

(1, 'Sunbear', 0.8787856)

(2, 'Sunbear', 0.32679325)

(1, 'Sunbear', 0.79356045)


Here is what i wanted to do:



To take the majority values that appeared for every 10 ( or more) returned values for boxes, classId and confidence (average value for this), to eliminate random fluctuation. Here are part of my codes,



 classIds = []
confidences = []
boxes = []
for out in outs:
for detection in out:
scores = detection[5:]
classId = np.argmax(scores)
confidence = scores[classId]
if confidence > confThreshold:
center_x = int(detection[0] * frameWidth)
center_y = int(detection[1] * frameHeight)
width = int(detection[2] * frameWidth)
height = int(detection[3] * frameHeight)
left = int(center_x - width / 2)
top = int(center_y - height / 2)
classIds.append(classId)
confidences.append(float(confidence))
boxes.append([left, top, width, height])
if classId ==0:
classId = 'Asian_elephant'
elif classId ==1:
classId = 'Sunbear'
elif classId ==2:
classId = 'Tapir'
#print ()
#logging.debug('%s %s %s', len(boxes), confidence,classId)
#logging.debug(boxes)
print ((len(boxes),classId,confidence))


Here is what I am trying to do:



If classId of 'Sunbear' appeared 5 times or more continuously , it will print the returned values and the count will reset back to 0 or else it will keep resetting to zero till the condition is met.



 count=0
while classId=='Sunbear':
count+=1
if count>=5:
print ((len(boxes),classId,confidence))
break


but somehow the returned values are the same in or outside the loop. Is this the right way of doing this, or there is some more efficient ways to do it. Please bear with me, I am new to programming, thanks in advance.







python object-detection






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 6:39









gameon67

1,4719 silver badges28 bronze badges




1,4719 silver badges28 bronze badges










asked Mar 26 at 2:35









shijishiji

1




1












  • what's the result that you got?

    – gameon67
    Mar 26 at 4:19











  • @gameon67 something like this (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.8578589) (1, 'Sunbear', 0.8578589) (2, 'Sunbear', 0.29979056) (2, 'Sunbear', 0.29979056) (1, 'Sunbear', 0.8787856) (1, 'Sunbear', 0.8787856) (2, 'Sunbear', 0.32679325) (2, 'Sunbear', 0.32679325) (1, 'Sunbear', 0.79356045) (1, 'Sunbear', 0.79356045) as you can see both inside and outside (loop) values are the same

    – shiji
    Mar 26 at 7:26


















  • what's the result that you got?

    – gameon67
    Mar 26 at 4:19











  • @gameon67 something like this (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.8578589) (1, 'Sunbear', 0.8578589) (2, 'Sunbear', 0.29979056) (2, 'Sunbear', 0.29979056) (1, 'Sunbear', 0.8787856) (1, 'Sunbear', 0.8787856) (2, 'Sunbear', 0.32679325) (2, 'Sunbear', 0.32679325) (1, 'Sunbear', 0.79356045) (1, 'Sunbear', 0.79356045) as you can see both inside and outside (loop) values are the same

    – shiji
    Mar 26 at 7:26

















what's the result that you got?

– gameon67
Mar 26 at 4:19





what's the result that you got?

– gameon67
Mar 26 at 4:19













@gameon67 something like this (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.8578589) (1, 'Sunbear', 0.8578589) (2, 'Sunbear', 0.29979056) (2, 'Sunbear', 0.29979056) (1, 'Sunbear', 0.8787856) (1, 'Sunbear', 0.8787856) (2, 'Sunbear', 0.32679325) (2, 'Sunbear', 0.32679325) (1, 'Sunbear', 0.79356045) (1, 'Sunbear', 0.79356045) as you can see both inside and outside (loop) values are the same

– shiji
Mar 26 at 7:26






@gameon67 something like this (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.91407496) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.93277943) (1, 'Sunbear', 0.8578589) (1, 'Sunbear', 0.8578589) (2, 'Sunbear', 0.29979056) (2, 'Sunbear', 0.29979056) (1, 'Sunbear', 0.8787856) (1, 'Sunbear', 0.8787856) (2, 'Sunbear', 0.32679325) (2, 'Sunbear', 0.32679325) (1, 'Sunbear', 0.79356045) (1, 'Sunbear', 0.79356045) as you can see both inside and outside (loop) values are the same

– shiji
Mar 26 at 7:26













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349054%2ffiltering-returned-values-variable-with-majority-votes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55349054%2ffiltering-returned-values-variable-with-majority-votes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현