[Tutor] Opencv

2015-09-19 Thread Ahmed AL-Masri
Dear fellows,
I have a project for hand detection as the person wave his hand than give an 
action.
I am trying to use the current library in opencv using the haar cascade. I use 
the following code with the available xml data base from internet But it seems 
that the data base is not good enough or the code is not correct because 
sometimes it detect other objects as well.
do you have any idea how we can use the opencv or another library to detect the 
hand for different scale or how to build good xml database

Thanks a lot for your cooperation and support.Ahmed
  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python GUI Tkinter Button arrangement

2011-02-16 Thread Ahmed AL-Masri

I suggest to use boa constructor if you are new learning.
just google it. very easy tool to create your interface

--
From: "Ganesh Kumar" 
Sent: Wednesday, February 16, 2011 6:43 PM
To: 
Subject: [Tutor] Python GUI Tkinter Button arrangement


Hi..

I am new to python , i have creating one application user
agreement..using Tkinter, The Content

of the agreement will reading one file...Agree button will click means
enable next button. And activate script,

Quit button for exit the program,, Dis agree means one warning message
will show up..

all are working but one buttons are top of the screen.  i want button
in bottom of the frame plz. help me..

this my source code


Source Code

http://pastebin.com/Lm5teAtS

Thanks in Advance
-Ganesh.





--
Did I learn something today? If not, I wasted it.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] gauge of the fram

2010-10-31 Thread Ahmed AL-Masri
Hi all,

sorry for long message but just read the red highlighted lines I am facing a 
problem with gauge update. I want to return a value from another script file 
but the problem is this value locate inside a loop. example :

the mean running script :

m=0
# this function to return any value from different script
def return_values(value):
global m
m= value
#print m
return value

def create(parent):
return ANN(parent)

[wxID_ANN, wxID_ANNBUTTON1, wxID_ANNFILEBROWSEBUTTON1, 
... so on
[wxID_ANNMENUFILEEXIT, wxID_ANNMENUFILEOPEN, wxID_ANNMENUFILESAVE, 
] = [wx.NewId() for _init_coll_menuFile_Items in range(3)]

[wxID_ANNMENUHELPABOUT] = [wx.NewId() for _init_coll_menuHelp_Items in range(1)]

class ANN(wx.Frame):
def _init_coll_menuBar1_Menus(self, parent):
# generated method, don't edit

parent.Append(menu=self.menuFile, title='File')
parent.Append(menu=self.menuHelp, title='Help')

def _init_coll_menuHelp_Items(self, parent):
# generated method, don't edit

def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_ANN, name='ANN', parent=prnt,
  pos=wx.Point(386, 130), size=wx.Size(715, 565),
  style=wx.DEFAULT_FRAME_STYLE, title='Artificial Neural Network')
self._init_utils()
self.SetClientSize(wx.Size(699, 527))
self.SetMenuBar(self.menuBar1)

self.panel1 = wx.Panel(id=wxID_ANNPANEL1, name='panel1', parent=self,
  pos=wx.Point(0, 0), size=wx.Size(699, 484),
  style=wx.TAB_TRAVERSAL)

self.gauge1 = wx.Gauge(id=wxID_ANNGAUGE1, name='gauge1',
  parent=self.panel2, pos=wx.Point(200, 112), range=100,
  size=wx.Size(100, 28), style=wx.GA_HORIZONTAL)
self.gauge1.SetValue(0)
self.gauge1.SetLabel('')
and so on ...

def OnNormtrainingButton(self, event):
self.data= self.fileBrowseButton1.GetValue()
target= self.fileBrowseButton2.GetValue()
import normalization
self.gauge1.Value=0
no= normalization.Norm()
no.read_norm_data(data)
#self.gauge1.Value=
print m


the second script is: normalization.py
def read_norm_data(self, inputsData):

self.pat=[]
tragauge=0;totalrange= float(len(open(inputsData).readlines())) #for the 
gauge process

while True:
# read the input data
line = f.readline()
if len(line)==0:
   break
inputs=line.split()
self.inputs=map(float,inputs)
#print self.inputs

# for the training data norm gauge process
self.traininggauge = ((tragauge+1)/totalrange)*100
tragauge=tragauge+1
ann.return_values(self.traininggauge) # HERE is the gauge 

from the last line I need this value to go in side the mean frame and update 
the gauge.
I can return the value into the mean file but couldn’t make it for the gauge 
cuz the gauge is inside the ANN class which I couldn’t go inside it.
I am trying to do that by make it as a global varible and update but it’s keep 
give me the same initial value m=0.

may be I can get it by sending the value and the gauge into a new script and 
update the gauge but I think this is not a proper way.

Any idea!
Best regards,___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Converting from unicode to nonstring

2010-10-15 Thread Ahmed AL-Masri
hi I faced this problem before and people of tutor helped me to solve it by 
only one line


ex.
a=input_raw("your non string")## I input 1,2,3,4  5 6 7 or u[1,2,3,4]
a.replace(",", " ","[","]","u").split() ## you can put any kind of unicode 
that you expect inside the " "

a=map(float, a)
print a

[1,2,3,4,5,6,7]


--
From: "Steven D'Aprano" 
Sent: Friday, October 15, 2010 9:37 PM
To: "Python Tutor" 
Subject: Re: [Tutor] Converting from unicode to nonstring


On Fri, 15 Oct 2010 09:26:48 pm David Hutto wrote:

Ok, Let me restate and hopefully further clarify.

1. I have a field for a wxpython app using matplotlib to display
2. I have a sqlite3 db which I'm retrieving information from


Both of those points are irrelevant.



3. The sqlitle data is returned as unicode: u'field'


Semi-relevant. What's important is that you have data as strings. It
could be coming from a text file:

data = open("my data.txt").read()

or from the user:

data = raw_input("Enter some data: ")

or any other source that gives a string. It makes no difference where it
comes from, the only thing that is important is that it is a string.



4. The portion of the matplotlib code is filled in, in a for x in y:


I don't really understand this sentence. What do you mean, portion of
code is filled in?

But in any case, it's irrelevant that you are doing something in a for
loop. For loop, while loop, using the data once only, who cares?



5. in plot(self.plot), self.plot is the variable I'm using from the
unicoded db field comes in from sqlite as u'[1,2,3,4]', which places
a string in quotes in that variables place:

plot(u'[1,2,3,4]')


Your sentence above is a bit convoluted, but I *think* this is what
you're trying to say:

- you take the string (which originally comes from the database, but it
doesn't matter where it comes from) and store it in self.plot;

- you pass self.plot to a function plot(); and

- since self.plot is a string, you are passing a string to the function
plot().

Presumably this is a problem, because plot() expects a list of ints, not
a string.



6. the plot(eval(self.plot)), changes the variable from the
u'[1,2,3,4]' to just [1,2,3,4]


Well, yes it does, so long as the string is perfectly formed, and so
long as it doesn't contain anything unexpected.

It is also slow, and unnecessary, and a bad habit to get into unless you
know exactly what you are doing.



7 As stated somewhere above, the float error has nothing to do with
the probel, only the fact that it was used as if I had placed ''
around the necessary data from the db field.


Huh?



8. If anyone has a way better than eval to convert the u'field' when
replacing a variable so that

self.plot = [1,2,3,4]

instead of

self.plot = u'[1,2,3,4]'


And now, finally, after a dozen or more emails and 8 points (most of
which are irrelevant!) we finally come to the real problem:

"I have a unicode string that looks like u'[1,2,3,4]' and I want to
convert it into a list [1, 2, 3, 4]. How do I do that?"

There are at least three solutions to this:

(1) eval. The benefit of eval is that it is a built-in, so you don't
have to do any programming. The downsides are that:

- it is very powerful, so it can do too much;
- it is dangerous if you can't trust the source of the data;
- because it does so much, it's a little slow;
- because it does so much, it will happily accept data that *should*
give you an error;
- on the other hand, it's also quite finicky about what it does accept,
and when it fails, the error messages may be cryptic.


(2) ast.literal_eval. The benefit of this is that it is a standard
library function starting in Python 2.6, so all you need do is import
the ast module. The downsides are:

- it is very powerful, so it can do too much;
- because it does so much, it will happily accept data that *should*
give you an error;
- on the other hand, it's also quite finicky about what it does accept,
and when it fails, the error messages may be cryptic.


(3) Write your own converter. The benefit of this is that you can make
it as flexible or as finicky as you like. The downside is that you have
to write it. But that's not actually very hard, and we can make sure
that we get a nice error message in the event of a problem:


def str_to_list(s):
   """Convert a string that looks like a list to a list of ints."""
   s = s.strip()  # ignore leading and trailing spaces
   if not (s.startswith("[") and s.endswith("]")):
   raise ValueError("string does not look like a list")
   s = s[1:-1]  # throw away the [ and ]
   s = s.replace(",", " ")
   result = []
   try:
   for word in s.split():
   result.append(int(word))
   except ValueError:
   raise ValueError("item `%s` does not look like an int" % word)
   return result



str_to_list(u' [1 , 2, 3, 15 , -3, 26,1, 7 ]   ')

[1, 2, 3, 15, -3, 26, 1, 7]


If you pass it faulty data, it gives you a nice error message:


str_to_list( u'{1:2}')

Traceback 

Re: [Tutor] OpenMP

2010-10-10 Thread Ahmed AL-Masri

Thanks a lots. it's really helpful,, I am reading it

--
From: "Emile van Sebille" 
Sent: Sunday, October 10, 2010 11:51 PM
To: 
Subject: Re: [Tutor] OpenMP


On 10/9/2010 9:45 PM Ahmed AL-Masri said...


Thanks for fast responding. I will try to use the threads and see how the
performance would be.. actually I am using that for my artificial neural
network and the problem is regarding to the ANN limitation when I used a
big
no of inputs. so one way to overcome this problem is by distributing and
now
I have like 3 networks in my system with slow processing. May be parallel
could have little effort.



You may also find stackless helpful at http://www.stackless.com which 
forms the backend of EVE Online and claims "large scale shared state 
simulation across tens of thousands of CPUs"


Emile


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OpenMP

2010-10-09 Thread Ahmed AL-Masri


Thanks for fast responding. I will try to use the threads and see how the
performance would be.. actually I am using that for my artificial neural
network and the problem is regarding to the ANN limitation when I used a 
big
no of inputs. so one way to overcome this problem is by distributing and 
now

I have like 3 networks in my system with slow processing. May be parallel
could have little effort.



Depending on how long running these processes are you may be able
to separate them out completely into separate server processes
in true client server mode. Effectively creating a network process for
each network then have a load balances so that each incoming
request gets sent to one of the server processes. That way you
can scale linearly by adding moreservers as required (the load
balancer starting a new process each time the number of active
requests passes a given limit.) This is how many uindustrial scale
databases handle high processing loads, each SQL request is validated
and if OK passed to a query server, the queries are distributed over
the available servers to ensure even loading and each server can
run on separate CPUs as needed (but still controlled by the OS).

The downside of this is of course the complexity of writing the
loadbalancer which must track all incoming requests and which
server they are on and also handle the responses from the servers
when complete, making sure they go back to the right source.
Its a little bit like writing a web server... or at least the listener 
part.


HTH,

Alan G.



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] OpenMP

2010-10-09 Thread Ahmed AL-Masri
Hi, 
I have searched about how to use openMP using python and I couldn't fine any 
helpful info. anyone can help me on this.

My idea is that to use the different processer core for each section. 
for ex.
lets say I have two loops and I want to test in which processer go through.
## core one should handle this 
a=[]
for I in range (100):
   s= 10*I
   a.append( s)

## core two should handle this
b=[]
for f in range (100):
   h= 10*f
   b.append( h)

## collecting the data in one data file 
data=[a, b]

my question is how to do that and is it possible in python to go from line to 
line after give the order to core one to process than we go to next core for 
the second process..

Really interesting to speed up the process based on no of CPUs that we have 
using python. 
Looking forward to seeing your suggestions,
Best regards,
Ahmed___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] input and raw input

2010-09-25 Thread Ahmed AL-Masri
Hi,
any one have an idea about how we can input many number in the one time and 
change it to list.
for example:

a=input("Enter the number of your class in the school:") # the number can 
be enter as: 12,13,14 or 12 13 14 with a space in between.

now how I can put these numbers into list like b=[12,13,14] with len( a ) =3

I tried with that but it's working only for a numbers less than 10 ex. 1,2,3 or 
1 2 3 but it's not when I go for numbers higher than 10 like in example above.

a=raw_input("Enter the number of your class in the school:")
m=[]
 for I range (len( a)):
if a[I]==',':
pass
elif a[I]==' ':
pass
else:
m.append(a[I])
m=map(float,m)
print m;print len( m )
>> [1,2,3]
>> 3

looking forward to seeing your help,
regards,
Ahmed


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] append in new file??

2010-07-27 Thread Ahmed AL-Masri
hello;

I need help in append a data in new file. the problem is the new data are 
generated in every run.
so at the end I should get all the changes in one file (means for all running) 
if I run 2 times so should get couple of data set.
note all outputs in txt file.
ex:
this is the first run data 
1.0362 1.015 1.011 0.9948 1.0024 0.9936
0.9129 0.9184 0.9868 0.9682 0.975 0.8953
1.0627 1.0517 1.0306 1.0387 1.0501 1.0485
1.0467 1.0342 1.0389 1.0109 1.0107 1.0066

next run the data changes in the same output file 
1.020 1.043 1.111 0.343 1.454 1.999
0.9129 0.9184 0.9868 0.9682 0.975 0.8953
1.0555 1. 1.333 1. 1. 1.
1. 1. 1. 1. 1. 1.

the appended file should be 
1.0362 1.015 1.011 0.9948 1.0024 0.9936
0.9129 0.9184 0.9868 0.9682 0.975 0.8953
1.0627 1.0517 1.0306 1.0387 1.0501 1.0485
1.0467 1.0342 1.0389 1.0109 1.0107 1.0066
1.020 1.043 1.111 0.343 1.454 1.999
0.9129 0.9184 0.9868 0.9682 0.975 0.8953
1.0555 1. 1.333 1. 1. 1.
1. 1. 1. 1. 1. 1.

more run more data will generate.

I tried so many times without any result.
t=open('old data'.txt')
d=open('new data.txt','w')

while True:
line=t.readline()
if len(line) ==0:
  break
volt=line.split()
volt=map(float, volt)
for i in range (len(line.split())):
d.write(str(volt[i])+' ')
d.write('\n')
d.close

but this only bring as same as the old file.

also I found some codes from the committee and tried but still not working.
import sys

def check_dup(fd1):
print fd1
fd1.seek(0,0)
list1=[]
while not done:
x = fd1.readline()
if x == "":
break
else:
list1.append(x)
return list1


fname = 'new data.txt'

fd = open(fname,'a+')
print fd

t=open('old data'.txt'
while not done:
while True:
line=t.readline()
if len(line) ==0:
break
volt=line.split()
volt=map(float, volt)
for i in range (len(line.split())):
print str
flag = check_dup(fd)
print flag
fd.seek(0,2)
fd.write(str(volt[i]) + ' ')
fd.write('\n')
break

looking forward for prompt response,
best regards,

Ahmed Naufal  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Time

2010-06-22 Thread Ahmed AL-Masri
Hi, 
I would calculate the running time of my simulation code.
any one know how to do that?

example

def demo():
### the starting point of time should be 0
 f.simulate(data)
### the end of the class so need to find the time in Sec.?
### print time in sec.
if __name__ == '__main__':
demo()

look forward to seeing the answer,

Thanks a lot,
A. Naufal___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] requesting a help

2010-05-23 Thread Ahmed AL-Masri


I am facing the same problem that little complicated.
I have this kind of data in a file and actually it's coming from another class 
and it's in formex:0 00 11 01 1and another data which it's in form :0110so now 
what I need to put it in form data= [[[0,0],[0]],  [[0,1],[1]], 
[[1,0],[1]],[[1,1],[0]]]
that is the form for a class that I can use the [0,1] is the inputs and 
inputs[0] is = 0 and inputs[1] is = to 1 . the same thing to the output[0] is = 
0 and so onok, now this is the problem I have successes to to that reading from 
file in form0 00 11 01 1the output0110and I write it in a file called it data 
in the new form which is exactly what I want in form   [[[0,0],[0]],
  [[0,1],[1]],  [[1,0],[1]],[[1,1],[0]],]but I got a problem. I cannot 
use this as a data when I read it from the data file cuz it's string and I 
tried to use int but couldn`t solve it yet.wish you can help me to find the 
solution in this problemether I can read the data from the original file and 
deal with it separately or write it to file and read it again which I am trying 
to do
f=open('data.txt')t=open('target.txt')n=file('newdata.txt','w')
def arange (inputs, targets, outputfile):  casesNo = len (inputs.readline())
for s in range (casesNo):for line in inputs:data=line.rsplit()  
  i=','.join(data)breakfor line1 in targets:
data1=line1.rsplit()#print data1[0]u=','.join(data1)z= 
str(i)w= str(u)outputfile.write('[[%s],' % (z)+ '[%s]], \n' 
%(w))breakoutputfile.close()arange(f,t,n) # f : input data, 
t: target data, n: outputfilelooking to hearing from you as soon as,once again 
thanks for your help and cooperation,
Regards, 

  
Hotmail: Trusted email with Microsoft’s powerful SPAM protection. Sign up now.  
  
_
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor