|
OK fixed the problem: removal of the struct for the mouse and replacement of the constant for themouse from 513 to 516
|
|
|
|
|
I completed the first step in my project, and with help from a few great people on this forum, I managed to get my edge detection algorithm to work adequately. Now on to my next goal. I have the edge detected video feed and can access all of its properties. What do you guys think is the best approach for judging the distance of a line on an image from the camera (robot). Lets say I can obtain the variables like angle of lens, angle of view, etc. What can I do with them in order to obtain distance data? Hough transformation works only for straight lines, so I am not sure how to approach this dilemma.
|
|
|
|
|
|
Thanks a bunch, btw what i meant by "only works on straight lines" was that i would encounter curved lines so it might not work well, but that you for the link, its going to help tremendously.
|
|
|
|
|
you're welcome.
|
|
|
|
|
Hi all,
I've wasted a day just trying to get a simple pointer back to C# from C++!
I have a C++ DLL returning an int* to a C# program. The problem is the int* in C# remains null after the assignment.
When I assign the C++ result to an IntPtr, I get a correct non-null value. However any attempt to assign this to an int* instantly results in null.
I've tried (from C#):
IntPtr intp = cppFunction ();
int* pi = (int *) intp;
int* pi = (int *) intp.ToPointer ();
void* vp = intp.ToPointer ();
int* pi = (int *) vp;
I then gave up on simple assignment, and tried to get the value by reference:
C#:
[DllImport("vdrdll.dll", EntryPoint = @"?getLineContentsAsArg@@YAXAAPAH@Z")]
public unsafe static extern void getLineContentsAsArg (ref int* lca);
C++:
DLLEXPORT void getLineContentsAsArg (int*& lca)
{
lca = calculateLineContents ();
}
A non-null pointer value is assigned in the DLL, but when it gets back to C#, it's null.
Can anyone tell me how to get an int* back to C#?
Thanks!
Alan
|
|
|
|
|
Hi Alan,
I don't know how to get an int*, I never needed this. I avoid pointers, and when I do want them (mainly for performance reasons, e.g. in image processing) I keep them very local.
Are you sure you need to pass int* over the managed/unmanaged border?
You might get away with the IntPtr you have, by using Marshal.WriteIntPtr and Marshal.ReadIntPtr;
or there may be a more elegant way to solve your specific problem. Care to elaborate?
|
|
|
|
|
Hi again Luc,
I'll look into your Marshal suggestions and see if they help. Thanks!
I'm doing image processing and most of it is in C++ because it's faster. One result is an array of ints, and I need to get it back to C#, which is why the pointer is used.
|
|
|
|
|
Alan,
if lots of ints need to go to the managed world, a Marshal method call per int obviously is a bad idea.
[ADDED] Marshal.Copy would then be the obvious choice. [/ADDED]
However the best performance is achieved by:
- allocating a managed array
- getting its pointer (use GCHandle class)
- passing it to the native world so it gets filled
- when native is done, unpin and enjoy.
That way marshaling is completely free, no data got ever copied.
If the array size is not known beforehand, I either allocate it way too large, or split the native code in two functions, one that returns the required size, and one that fills the array.
[ADDED] It is also possible to provide a delegate so the native world can call it to get the array once the size is known [/ADDED]
modified on Thursday, May 7, 2009 1:10 PM
|
|
|
|
|
Thanks Luc! It worked.
modified on Thursday, May 7, 2009 2:49 PM
|
|
|
|
|
you're welcome.
|
|
|
|
|
Do you have to explicitly flag the array to keep the GC from moving it before the native call returns?
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Hi Dan,
the object has to be pinned since the GC could suddenly run and move objects around; say another thread kicks in and needs memory.
AFAIK there are three ways to achieve that:
1. use the "fixed" keyword, it will pin behind the scenes;
2. use GCHandle.Alloc, GCHandle.AddrOfPinnedObject and GCHandle.Free;
3. use automatic marshaling; it will also pin objects for you.
1. is OK for simple situations
2. is what I use most of all; it is fine when the pointer remains in use in the native world after the first native function call returns (e.g. when initiating asynchronous I/O). One should not forget to free the GCHandle when done!
3. is not always clear how things get done, quite often data gets copied which I don't like in general. The performance gained by using native code (say for image processing) is lost by one or two silly copy operations that don't accomplish anything. My main use for automatic marshaling is sending Unicode strings to ASCII-oriented C code.
|
|
|
|
|
In C# 2005 (.Net 2.0), while working with a toolstrip, if its TabStop property is set to TRUE and there are two comboboxes and a button in the toolstrip, why doesn't the button get any focus when the focus is moved from one control to another by pressing the TAB Key. This problem doesn't occur when the TabStop property of the toolstrip is FALSE. But I need the TabStop property to be TRUE.
Another problem is while the TabStop property of toolstrip is FALSE, if u try to set focus to one of the comboboxes in toolstrip during the form load event, it's not working. How to solve these 2 problems? Thanks.
|
|
|
|
|
I need to add a confirmation box while updating modifications in the Edit part via GridView_RowUpdate.
MessageBox only works as server-side, but not client-side.
I made some search and found that I can extend the properties of commandfield.
But the problem is how can I call the new extended namespace/class from my current page in website?
Thanks a lot for your response.
|
|
|
|
|
Dear Codeproject readers,
There is a shop window with four monitors. I have to play four different powerpoint slideshows (ppt presentations) on each monitor. I tried to find attributes and properties about displays in
PowerPoint.Application
PowerPoint.Presentation
but I did not find anything.
I have a single computer with four monitors(multi monitor video card) and four sound cards. I would like to display four different ppt on the monitors (multimedia monitor = there is a speaker on it) and if the ppt contains sound then play it on the corresponding speaker simultaneously.
I know there is a chance that this is impossible
Do I buy four PC instead ?
Thank you in advance,
Dave
|
|
|
|
|
Try them strange people in the hardware and devices forum...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Vote me 1 all you like - powerpoint is still not C#
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
There is a whole Power point "using" in c# this is not a hardware question.. Windows handles the hardwares.
|
|
|
|
|
You need a strange person to move a window? Very strange!
|
|
|
|
|
Luc Pattyn wrote: You need a strange person to move a window
Have you seen my builder?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
when multiple monitors all contribute to a single desktop, they have their own position in the coordinate system of the desktop; the first monitor typically has its top left corner at (0,0); the others can be anywhere (you can drag them in the Display Properties dialog).
Have a look at the Screen class to determine the exact coordinates.
Then launch your app(s) and move their main window; the Process class gives you the MainWindowHandle; you then can send a move message (using P/Invoke) with the appropriate parameters.
|
|
|
|
|
Hi Luc,
Thank you for your answer.
This can be a solution, If I use pptview.exe to show the ppt as a process than I can do this. I hope I can tun multiply pptview.exe.
Let's say the display is done. But how can I redirect the sound output of a Process to a specified sound device (ppt-s can contain sounds usually played on the primary sound device). This is not good because I would like to show ppt-s on different screens with its own speakers.
Can I do anything with the sound?
I know this is a hard question but four PC cost much more money than one.
Dave
|
|
|
|
|
Sorry, I have no idea about multiple audio.
|
|
|
|
|
Hi all,
I'm doing a program that saves customer details to the database and I'm using NHibernate. I'm very new in it and I'm getting help from the net. I have a problem compiling the mapping file, I get the following error:
"Could not compile the mapping document: Customer.hbm.xml"
I don't have an idea of what I did wrong. Please, if you know what I missed or did wrong, I'd really appreciate your help/advice. Thanks.
Here is my class:
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
namespace NHibernate_Demo
{
class Program
{
static void Main(string[] args)
{
// Loads the NHibernate Types to prepare for Serialization
Configuration cfg = new Configuration();
cfg.Configure();
//cfg.AddAssembly(typeof(NHibernate_Demo.Customer).Assembly);
//cfg.AddClass(typeof(Customer));
cfg.AddFile("Customer.hbm.xml");
//Opens a session to NHiberbate to allow us to work with objects
ISessionFactory sessionsF = cfg.BuildSessionFactory();
//let ISessiionFactory open connection
ISession sessionS = sessionsF.OpenSession();
ITransaction transaction = sessionS.BeginTransaction();
{
Customer customer = (Customer)
sessionS.Load(typeof(Customer), "ALFKI");
// Show the Contact Name of the Customer
//MessageBox.Show(customer.ContactName);
sessionS.Close();
}
}
}
}
I get an error at this line:
cfg.AddFile("Customer.hbm.xml");
Thanks.
|
|
|
|