Posts

python - python2.7 histogram comparison - white background anomaly -

my program's purpose take 2 images , decide how similar are. im not talking here identical, similarity. example, if take 2 screenshots of 2 different pages of same website, theme colors similar , therefor want program declare similar. my problem starts when both images have white background pretty takes on histogram calculation (over 30% of image white , rest distributed). in case, cv2.comparehist (using correlation method, works other cases) gives bad results, is, grade high though different. i have thought taking white (255) off histogram before comparing, requires me calculate histogram 256 bins, not when want check similarity (i thought using 32 or 64 bins best) unfortunately cant add images im working due legal reasons if can idea, or code solves grateful thank much you can remove white color, rebin histogra , compare: compute histrogram 256 bins. remove white bin (or make zero). regroup bins have 64 bins adding values of 4 consecutive bins. pe...

spring security - Remember-me cookie deleted after app restart - is this OK? -

i have remember-me implemented in spring boot app, can see cookie created correctly after login, proper expiration time etc. cookie doesnt survive app restart on tomcat server. scenario simple. user login remember me , cookie available in browser. app redeploy in tomcat , now, when user refreshes app in browser window, logged out , cookie deleted browser. shouldn't cookie survive , allow automatic login app restarts in tomcat? here snippet springboot security config. app.logout().deletecookies("nh_remember").logoutsuccessurl("/").logouturl("/logout").permitall().and().rememberme().remembermecookiename("nh_remember").tokenvalidityseconds(1209600).key("xxxxxxxx") you have persist token between restarts of tomcat. check out documentation: http://docs.spring.io/spring-security/site/docs/current/reference/html/remember-me.html specifically need setup persistenttokenbasedremembermeservices contains information database...

swift - change uinavigation bar item position -

Image
how can change uinavigation baritem position leftbarbuttonitem rightbarbuttonitem function for need create custom barbuttonitem , set right side, need hide default backbarbutton , try thing this. add below code inside viewdidload . self.navigationitem.hidesbackbutton = true let btnforward = uibutton(frame: cgrect(x: 0, y: 0, width: 25, height: 25)) btnforward.setimage(uiimage(named: "forward_arrow"), forstate: .normal) btnforward.addtarget(self, action: #selector(self.buttonaction(_:)), forcontrolevents: .touchupinside) let backitem = uibarbuttonitem(customview: btnforward) self.navigationitem.rightbarbuttonitem = backitem after add action method inside viewcontroller func buttonaction(sender: uibutton) { self.navigationcontroller?.popviewcontrolleranimated(true) }

swift3 - How to declare exponent/power operator with new precedencegroup in Swift 3? -

there's been change in swift 3 xcode 8 beta 6 , i'm not able declare operator power did before: infix operator ^^ { } public func ^^ (radix: double, power: double) -> double { return pow((radix), (power)) } i've read bit , there's new change been introduced in xcode 8 beta 6 from i'm guessing have declare precedence group , use operator this: precedencegroup exponentiativeprecedence {} infix operator ^^: exponentiativeprecedence public func ^^ (radix: double, power: double) -> double { return pow((radix), (power)) } am going in right direction make work? should put inside {} of precedence group? my final aim able make power operations simple operator in swift, e.g.: 10 ^^ -12 10 ^^ -24 your code compiles , runs – don't need define precedence relationship or associativity if you're using operator in isolation, such in example gave: 10 ^^ -12 10 ^^ -24 however, if want work other operators, chaining multiple expon...

android - Storing list of position in sharedPreferences, and retrieve in another activity -

i want similar this , have used cardview recyclerview. added favourite button cardview below can see full code. in recyclerview adapter print toast per position , working fine, need save int value of position in shared preferences in arraylist , display arraylist in next intent. this recyclerview adapter public void onbindviewholder(nameviewholder holder, final int position) { holder.textview.settext(names.get(position).textview); holder.favourite.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { sharedpreferences sp = preferencemanager.getdefaultsharedpreferences(view.getcontext()); sharedpreferences.editor editor = sp.edit(); editor.putint("key", position); //may or may not be. //add code here save position in array toast.maketext(view.getcontext(),"fav "+position,toast.length_short).show(); } }); cardview.xml <?x...

hibernate - Why Document Fields Still Have Uppercase Characters after Using LowerCaseFilterFactory? -

i think analyzer should apply both indexing , search processes, correct? if true, why document fields still have uppercase characters after using lowercasefilterfactory filter in analyzer? i use luke check document fields. here related code. @indexed @analyzerdef(name = "remarksanalyzer", tokenizer = @tokenizerdef(factory = standardtokenizerfactory.class) , filters = { @tokenfilterdef(factory = lowercasefilterfactory.class), @tokenfilterdef(factory = snowballporterfilterfactory.class, params = { @parameter(name = "language", value = "english") }) }) public class book { ... @field(store = store.yes) @analyzer(definition = "remarksanalyzer") private string remarks; ... } did try search on index lowercased words? i'm pretty sure work. the fact is, if use store=store.yes, store unanalyzed string in index , analyzed tokens. might allow use highlighter instance: highlighted s...

curl - PHP echo CSRF & STATE not appearing -

greetings stacksoverflow devs, i'm trying figure out earlier why hidden input values @ website not appearing when try echo , used preg_match_all , made hidden value post. i want echo both @ same time problem couz it's not appearing. here code: <?php function get_data($url) { $ch = curl_init(); $timeout = 10; curl_setopt($ch,curlopt_url,$url); curl_setopt($ch,curlopt_returntransfer,1); curl_setopt($ch,curlopt_connecttimeout,$timeout); $data = curl_exec($ch); curl_close($ch); return $data; } $returned_content = get_data('https://secure.tesco.com/account/en-gb/login'); $container = $returned_content; preg_match_all('(<form\s.*</form>)', $container, $forms); print_r($forms); $_post['_csrf'] = $csrf; $_post['state'] = $state; echo "<font color=red><b>csrf</b></font> : ".$csrf."<br/>"; echo "<font color=red...