|
You sir, are too modest.
Luc Pattyn wrote: and any visible looping
Way to cover your ass!
Curiously, I'll have to dig into the GetRange code now...
|
|
|
|
|
I'm sure you'll find a loop inside, as well as inside List.ToArray() and Array.Copy() .
And even if List.GetRange() were returning an IEnumerable rather than a list, there still would be a loop doing the hard work.
|
|
|
|
|
I've just seen this and happened to have reflector open so I've had a look!
GetRange uses Array.Copy to copy to a new list:
List<T> list = new List<T>(count);
Array.Copy(this._items, index, list._items, 0, count);
list._size = count;
return list;
as is ToArray but to an array instead:
T[] destinationArray = new T[this._size];
Array.Copy(this._items, 0, destinationArray, 0, this._size);
return destinationArray;
Now quite what Array.Copy is doing I'm not 100% sure as it's an extern function, so perhaps it's using unmanaged code to block copy?
|
|
|
|
|
|
IMO you're right!
|
|
|
|
|
Use ArrayList.
example:
ArrayList AryObj= new ArrayList();
for (int i=0; i < selec.Item.Count; i++)
{
AryObj.Add(selec.Item[i].Text);
}
|
|
|
|
|
That is bad.
ArrayList is the only list that existed back in .NET 1.0 and 1.1; since 2.0 we have generic lists such as List<int> and there is no real use for ArrayList anymore, it is just an equivalent to List<object> and therefore it is superfluous as a type.
Furthermore it does not contribute at all to the solution of the OP's problem.
|
|
|
|
|
Thanks 
|
|
|
|
|
Dear All,
Would you please advise if there's certain problems in EMGU Library or Accord Library???
I made a program to recognize Sign language using image processing , feature extraction & HMM but I'm not achieving the needed accuracy.
the number of correct recognitions is tooooo much small and I can't apply my project with such errors.
I highly appreciate your help & cooperation.
All the best...
Rima
|
|
|
|
|
Don't just post this everywhere - it duplicates work and can annoy people.
Either post it in QA or post it in the forums - but not both!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
OK & Sorry for this mistake
|
|
|
|
|
RimaTeliani wrote: advise if there's certain problems in EMGU Library or Accord Library?
What problems? If you need help then you need to describe your problem in better detail.
|
|
|
|
|
i don't know actually where is the problem, but I couldn't recognize any video outside the database.
I'm asking if you have faced problems in the HMM from Accord Library or in functions from EMGU library since I don't think that the problem is in the Algorithm.
Many thanks in advance & Best regards,
|
|
|
|
|
RimaTeliani wrote: I made a program to recognize Sign language using image processing , feature extraction & HMM but I'm not achieving the needed accuracy.
the number of correct recognitions is tooooo much small and I can't apply my project with such errors.
You'll need a neural network, and train it on a specific user. Do you "speak" sign? If not, I'd strongly suggest learning baby-sign, roughly a 100 words worth, easy to learn, and gives a wonderful insight in what language is.
My movements are erratic, sometimes closely to spastic. It's hard for a human to determine whether I meant "father" or "mother", if my hand is halfway up my nose. Computers will have the same problem.
That's not much of a problem in the real-world, as there's something like a "context" to a story. If we're talking about women's clothes, you can easily deduce that I meant "mother", not "father".
You've chosen quite a difficult project - but the toughest are often the most rewarding.
Bastard Programmer from Hell
|
|
|
|
|
Dear Eddy,
I highly appreciate your reply.
I have read a lot about sign language and the difficulties of it in different languages but I tried to get over them.
I specified the aim of my project to recognize about 25 words in this initial stage. those words contain movement so my deal is with videos rather than with static images.
as I've noticed, most of the researches in this domain used HMM and got best results than using ANN which is considered as old technique compared to HMM. So, I used HMM and trained it on multiple users.
Can you help me more please.
thanks in advance
|
|
|
|
|
RimaTeliani wrote: I specified the aim of my project to recognize about 25 words in this initial stage. those words contain movement so my deal is with videos rather than with static images.
The hard part therein would be determining when a new word starts, and when it would end. I'd probably select static snapshots at a set interval to analyze, as opposed to a stream.
RimaTeliani wrote: as I've noticed, most of the researches in this domain used HMM and got best results than using ANN which is considered as old technique compared to HMM.
Seems to fit the problem better than a neural network; the Wikipedia shows some links to some more elaborate versions of the algo that are a bit beyond my scope.
RimaTeliani wrote: Can you help me more please.
Not beyond what I already told you.
Bastard Programmer from Hell
|
|
|
|
|
Many thanks Eddy
All the best
|
|
|
|
|
Hi,
I am writing an automated printer driver performance measuring tool. I have one problem that I need to fix.
Please check the sample code below.
What I need to do is, when I add the job to the print queue, I need to "poll" for the "isDeleted" status (or if possible, "isCompleted" status) and display the time (that part is not written in the sample code) it took to finish the job. In this case, "finish" means that the PRN file has been created. (The port of the printer is set to Local port: PRN file path.)
For this, I need to add a pause (of suitably low amount so that it doesn't affect the time) where I have put a comment in the code below.
I can easily do this with a timer, but it got a bit complicated when i kept on adding features. (i would be adding a list of job, would be backing up the PRN files, get time measurement, use two drivers and compare performance etc. etc.)
using System;
using System.Windows.Forms;
using System.Printing;
using System.Threading;
namespace AddJob
{
public partial class frmAddJob : Form
{
public frmAddJob()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Thread printingThread = new Thread(printXPS);
printingThread.SetApartmentState(ApartmentState.STA);
printingThread.Start();
}
private void printXPS()
{
LocalPrintServer lp = new LocalPrintServer();
PrintQueue pq = LocalPrintServer.GetDefaultPrintQueue();
try
{
PrintSystemJobInfo psji = pq.AddJob("myXPSJob", "C:\\test.xps", false);
while (psji.IsDeleted != true)
{
psji.Refresh();
}
MessageBox.Show("Done");
}
catch
{
MessageBox.Show("Error");
}
}
}
}
Does anyone have any tips for me?
|
|
|
|
|
1. you can pause a thread using Thread.Sleep
2. you should not perform blocking operations (such as Thread.Sleep) on the main thread
3. most often a timer is the right way for controlling progress
4. use the timer that fits your needs, there are several types. For simple periodic jobs in a WinForms environment, most often a System.Windows.Forms.Timer is the right one as it ticks on the main thread.
5. always prefer an event-driven approach over a polling approach
6. if you must poll, and a timer-based approach doesn't fit, consider using a BackgroundWorker instead (probably with Thread.Sleep now)
7. for file creation/deletion, the FileSystemWatcher class provides some useful events; warning: they signal the start of an action, not the termination of an action.
8. when "things get complicated while adding features", you probably failed to properly apply an object-oriented approach
9. it isn't adding features that causes complexity, it is brain twisting the wrong way.
|
|
|
|
|
|
can you tell me how to combine the edits for field1 and field2 together into the same edit? The fields need to be edited together.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IMpt.Interfaces;
using System.Data;
using System.Collections;
namespace Data.Transactions
{
public class Trans : BaseTransaction
{
#region TransactionType implementation methods
/// <summary>
/// Overrides BaseTransaction function to add additional columns
/// </summary>
/// <returns></returns>
public override List<ColumnNames> GetColumnNames()
{
List<ColumnNames> list = base.GetColumnNames();
list.Add(ColumnNames.filed1);
list.Add(ColumnNames.field2);
return list;
}
public override List<RuleError> ValidateData(DateTime receivedDate)
{
//Call the base class function to do
// common data validations
base.ValidateData(receivedDate);
DataTable excelData = ExcelDataTable;
IMptDataContext didc = new IMptDataContext();
Hashtable colMap = base.ColumnMap;
List<RuleError> masterList = new List<RuleError>();
string colName = ColumnNames.field2.ToString();
string field2ColName = colMap[colName].ToString();
colName = ColumnNames.filed1.ToString();
string field1ColName = colMap[colName].ToString();
int iEnd = excelData.Rows.Count;
for (int i = DataRowNumber - 1; i < iEnd; i++)
{
//First validate all common fields from ColumnMap
DataRow dr = excelData.Rows[i];
{
//Call Base class function to validate common fields
List<RuleError> list = Validate(dr, receivedDate, didc);
if (list == null)
list = new List<RuleError>();
string field1 = dr[field1ColName].ToString();
re = Validatefield1ible(field1);
if (re != null)
{
list.Add(re);
}
string colVal = dr[field2ColName].ToString();
re = Validatefield1(colVal);
if (re != null)
{
list.Add(re);
}
}
excelData.AcceptChanges();
didc.Dispose();
return masterList;
}
/// <summary>
/// Validates data and updates DataTable with error messages and Loads data into DB.
/// </summary>
/// <param name="dtData">Excel data to be loaded into database</param>
/// <param name="wb">ImWorkbook DB entity object.</param>
/// <returns>List of RuleError objects</returns>
public override List<RuleError> LoadData(ImportWkbk wb, string destDocLoc)
{
if (IsDupCheckRequired())
{
DateTime firstDate = new DateTime(1753, 1, 1);
//Create DB context
IMptDataContext didc = new IMptDataContext();
didc.CommandTimeout = AutoCode.SQL_CMD_TIMEOUT;
//Create list of master errors
List<RuleError> masterList = new List<RuleError>();
//Get the column map hashtable
Hashtable colMap = base.ColumnMap;
//Get the columns names from the mapping Hashtable
//Get the columns names from the mapping Hashtable
string colName = ColumnNames.field2.ToString();
string field2ColName = colMap[colName].ToString();
colName = ColumnNames.filed1.ToString();
string field1ColName = colMap[colName].ToString();
Hashtable htSubs = new Hashtable();
Int64 submissionID = 0;
VCust firstCust = null;
int iEnd = ExcelDataTable.Rows.Count;
for (int i = DataRowNumber - 1; i < iEnd; i++)
{
DataRow dr = ExcelDataTable.Rows[i];
try
{
//Get the cust id from database
//VCust nextCust = FindCust(didc, dr[cnColName].ToString());
VCust nextCust = FindCust(dr[cnColName].ToString().Trim().ToUpper());
string field1 = dr[field1ColName].ToString().Trim().ToUpper();
lis.filed1 = field1.Length > 0 ? field1 : null;
string field2 = dr[field2ColName].ToString().Trim().ToUpper();
lis.field2 = field2.Length > 0 ? field2 : null;
didc.SubmitChanges();
didc.Dispose();
return null;
}
null;
string field1 = dr[field1ColName].ToString().ToUpper().Trim();
field1 = field1.Length > 0 ? field1 : null;
) &&
(
(field1 == null && d.filed1 == null) ||
(field1 == d.filed1)
) &&
(
(field2 == null && d.field2 == null) ||
(field2 == d.field2)
) &&
(
orderby d.Transaction_ID descending
select d).ToArray();
}
}
}
excelData.AcceptChanges();
didc.Dispose();
}
public RuleError Validatefield1ible(string field1)
{
RuleError re = null;
if (field1 == null || field1.Trim().Length < 1)
return null;
if (field1.Trim().ToUpper().Equals (field1ibleStatus.PART) ||
field1.Trim().ToUpper().Equals (field1ibleStatus.aLL)
)
{
return null;
}
re = new RuleError(RuleErrorCodes.OTHER, RuleErrorTypes.ERROR, "error 1");
return re;
}
/// <summary>
/// Validates Institutional Status value.
/// </summary>
/// <param name="field2us"></param>
/// <returns></returns>
public RuleError Validatefield1(string field2us)
{
RuleError re = null;
if (field2us == null || field2us.Trim().Length < 1)
return null;
if(field2us.Trim().ToUpper().Equals(field2.NO) ||
field2us.Trim().ToUpper().Equals(field2.YES) ||
field2us.Trim().ToUpper().Equals(field2.maybe)
)
{
return null;
}
re = new RuleError(RuleErrorCodes.OTHER, RuleErrorTypes.ERROR, "error 2.");
return re;
}
}
|
|
|
|
|
No.
But then, I'm not going to wade through that lot trying to work out what is going on.
Edit your question and add a code block to preserve the original formatting and indentation - (Just highlight the code, and press the "code" widget above the textbox). It will make it a lot more readable, and I might look at it then. But not now.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
closed this thread and started a new thread so the code was more readable.
|
|
|
|
|
That wasn't necessary, you could have just edited your original post
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Sorry, didn't read any of that as it wasn't properly formatted and indented. Please use PRE tags.
|
|
|
|