|
how to use the grabber filter can you tell me man
with illustrative code please
Miss With The Best And Die Like The Rest
|
|
|
|
|
Hello.
Here is the code, I am using to access my cam. The code is using an interop library for DirectX - something similar to DirectX.Capture.dll. I hope, you will understand it and it will help you.
<br />
Grabber grabber = new Grabber(this);<br />
<br />
<br />
Type srvType = Type.GetTypeFromCLSID(Clsid.FilterGraph);<br />
if (srvType == null)<br />
throw new ApplicationException("Failed creating filter graph");<br />
<br />
graphObj = Activator.CreateInstance(srvType);<br />
graph = (IGraphBuilder) graphObj;<br />
<br />
UCOMIBindCtx bindCtx = null;<br />
UCOMIMoniker moniker = null;<br />
int n = 0;<br />
<br />
if (Win32.CreateBindCtx(0, out bindCtx) == 0)<br />
{<br />
if (Win32.MkParseDisplayName(bindCtx, source, ref n, out moniker) == 0)<br />
{<br />
Guid filterId = typeof(IBaseFilter).GUID;<br />
moniker.BindToObject(null, null, ref filterId, out sourceObj);<br />
<br />
Marshal.ReleaseComObject(moniker);<br />
moniker = null;<br />
}<br />
Marshal.ReleaseComObject(bindCtx);<br />
bindCtx = null;<br />
}<br />
<br />
if (sourceObj == null)<br />
throw new ApplicationException("Failed creating device object for the moniker");<br />
<br />
sourceBase = (IBaseFilter) sourceObj ;<br />
<br />
srvType = Type.GetTypeFromCLSID(Clsid.SampleGrabber);<br />
if (srvType == null)<br />
throw new ApplicationException("Failed creating sample grabber");<br />
<br />
grabberObj = Activator.CreateInstance(srvType);<br />
sg = (ISampleGrabber) grabberObj;<br />
grabberBase = (IBaseFilter) grabberObj;<br />
<br />
graph.AddFilter(sourceBase, "source");<br />
graph.AddFilter(grabberBase, "grabber");<br />
<br />
AMMediaType mt = new AMMediaType();<br />
mt.majorType = MediaType.Video;<br />
mt.subType = MediaSubType.RGB24;<br />
sg.SetMediaType(mt);<br />
<br />
if (graph.Connect(DSTools.GetOutPin(sourceBase, 0), DSTools.GetInPin(grabberBase, 0)) < 0)<br />
throw new ApplicationException("Failed connecting filters");<br />
<br />
if (sg.GetConnectedMediaType(mt) == 0)<br />
{<br />
VideoInfoHeader vih = (VideoInfoHeader) Marshal.PtrToStructure(mt.formatPtr, typeof(VideoInfoHeader));<br />
<br />
System.Diagnostics.Debug.WriteLine("width = " + vih.BmiHeader.Width + ", height = " + vih.BmiHeader.Height);<br />
grabber.Width = vih.BmiHeader.Width;<br />
grabber.Height = vih.BmiHeader.Height;<br />
mt.Dispose();<br />
}<br />
<br />
graph.Render(DSTools.GetOutPin(grabberBase, 0));<br />
<br />
sg.SetBufferSamples(false);<br />
sg.SetOneShot(false);<br />
sg.SetCallback(grabber, 1);<br />
<br />
IVideoWindow win = (IVideoWindow) graphObj;<br />
win.put_AutoShow(false);<br />
win = null;<br />
<br />
mc = (IMediaControl) graphObj;<br />
<br />
mc.Run();<br />
And the next
<br />
private class Grabber : ISampleGrabberCB<br />
{<br />
private int width, height;<br />
<br />
public int Width<br />
{<br />
get { return width; }<br />
set { width = value; }<br />
}<br />
public int Height<br />
{<br />
get { return height; }<br />
set { height = value; }<br />
}<br />
<br />
public Grabber()<br />
{<br />
}<br />
<br />
public int SampleCB(double SampleTime, IntPtr pSample)<br />
{<br />
return 0;<br />
}<br />
<br />
public int BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)<br />
{<br />
System.Drawing.Bitmap img = new Bitmap(width, height, PixelFormat.Format24bppRgb);<br />
<br />
BitmapData bmData = img.LockBits(<br />
new Rectangle(0, 0, width, height),<br />
ImageLockMode.ReadWrite,<br />
PixelFormat.Format24bppRgb);<br />
<br />
int srcStride = bmData.Stride;<br />
int dstStride = bmData.Stride;<br />
<br />
int dst = bmData.Scan0.ToInt32() + dstStride * (height - 1);<br />
int src = pBuffer.ToInt32();<br />
<br />
for (int y = 0; y < height; y++)<br />
{<br />
Win32.memcpy(dst, src, srcStride);<br />
dst -= dstStride;<br />
src += srcStride;<br />
}<br />
<br />
img.UnlockBits(bmData);<br />
<br />
<br />
img.Dispose();<br />
<br />
return 0;<br />
}<br />
}<br />
|
|
|
|
|
I have the name of a button in a string and wish to change the text of the button e.g:
CString strTemp="button1";
Button btnTmp=(Button)FindControl(strTemp);
btnTemp.Text="New text";
But I cannot get it to complile, whatever using clauses I try. It cannot find defininition for FindControl.
How can I get at my button control from my string in a non ASP application.
thanks,
|
|
|
|
|
This is because there is no FindControl in the object the code lives in. I am making a big assumption but I bet you are in a Form object of some sort. You can be confusing the System.Web.UI.Control and System.Windows.Forms.Control objects. Without any more information I can not help you.
Beyond that, there are a number of ways to traverse the widget tree. The form itself has a property Controls which is a control collection it contains.
ps. How can you possibly use CString ?
|
|
|
|
|
hi how are you all ?
this is my next message in this website great message board .
iam developing new chat messenger that uses all possible chat options such as text transfer between clients and webcam images and also audio voice transfer
i used the namespace DirectX.Capture.dll
for capturing vedio from my webcam and audio and it works thank god
but what i need is to transfer these images instantly between client and the other connected client in private chat with the webcam and audio and i don't know how it works if any has any solution for that please send me notification to my email address at
-----------------------------------
matrix_623@yahoo.com
snouto@phreaker.net
-----------------------------------
Please Send me any help with that i will be very thoughtful for you .
Miss With The Best And Die Like The Rest
|
|
|
|
|
Use something like .NET remoting. There are many examples of using remoting on this site and also on MSDN and others. I suggest you look there. Basically, you convert your image into a byte[], send the bytes over using remoting, then recreate the image on the client side from the byte[].
So search around for .NET remoting, you should find some interesting examples. FYI, .NET remoting isn't the only way to do this, but it is currently the recommended way if both applications are .NET desktop apps.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
I tried to develope a basic empty asp.net appliaction.
When i tried to run it by F5 it executes properly .Bt then i addes a simple UI button control and tested event handling for simple clik event .
When i press F5 ,it start the browser and shows a message in status bar 'Web site found...waiitng for reply'And it hangs there .Instead if i manually open the form thru browser ,it opens..
I dont understand wats the problem
|
|
|
|
|
This post really belongs in the ASP.Net forum, but do you have a breakpoint set in the code? That would stop execution until you chose to continue.
If you're not sure, choose Debug -> Clear all Breakpoints.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
How can I implement following code in C# ?
static int a;
foo( &a ); // pass address of a
// a was changed to 123.
foo( int& a )
{
a = 123;
}
Thanks
|
|
|
|
|
|
Thank you a lot . I'm newby of C#, I don't know ref keyword. now I got it.
|
|
|
|
|
how can I create a map, and when I drag the map by the stylus, the map then change the view (move) according to stylus movement on pocketpc (.netCF).
|
|
|
|
|
How can i convert crystal report file to pdf
Thanks
|
|
|
|
|
Hi!!!
I want to create a bidimensional array of strings but I don't know how can I fill it with values.
I have this code but the problem is that I think it only fills one of the dimensions.
for ( int i = 0; i < 1; i++ )
{
for ( int j = 0; j < numRestrictions; j++ )
{
arrayPossibleValues[i,j] = arrayRestrictions[j];
}
}
Thanks in advance
Mónica Pinto
|
|
|
|
|
Hi
I have a simple C# Winforms app that needs to be deployed on various client PCs.
I know about XCopy deployment - just copy all the files and its done.
But i want to do more than that, create a GUI based app that lets the client choose the folder in which it can be installed in.
When the application executes it reads that value for looking at exe files.
regards
Rajiv.
rt7
|
|
|
|
|
Add a new project for your application solution. This project should be a Setup project. You can find it under New Project->Setup and Deployment Projects. Read the help on proceding further.
This will give you a MSI file which can be installed on the client applications using Windows Installer.
|
|
|
|
|
Hi! I'm having trouble trying to fill a DataSet with the results of a procedure I wrote. The procedure has 1 parameters and is composed of a select query (select id,text from Users where id=id_passed_by_param). My problem regards using this procedure to fill a DataSet. I was trying to do this:
try{
// create and open a connection object
conn = new SqlConnection(string_conn);
conn.Open();
SqlCommand cmd = new SqlCommand
("Proc", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@id", 1));
SqlDataAdapter da = new SqlDataAdapter(cmd);
// I'm stuck here...what can I do to fill the Dataset?
// normally I would do this:
// DataSet ds = new DataSet();
// da.fill(ds,"TableName");
// but in this case, what can I do?
}
finally
{
if (conn != null){
conn.Close();
}
}
Also I'm not exactly sure how I can execute the procedure...I don't want a DataReader (so I can't use the ExecuteReader()), unless I can somehow convert the data received by the procedure to the DataSet....Any help would be great!
|
|
|
|
|
TechnoSpike wrote:
// normally I would do this:
// DataSet ds = new DataSet();
// da.fill(ds,"TableName");
// but in this case, what can I do?
Exactly the same (Although I never normally add a table name). The rest of your code looks acceptable.
TechnoSpike wrote:
Also I'm not exactly sure how I can execute the procedure
The same way as any bit of SQL. Using DataAdapter.Fill() , Command.ExecuteNonQuery() , Command.ExecuteScalar() or Command.ExecuteDataReader()
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
You dont have to give the Table Name always
just specify the dataset object
da.fill(ds);
satish_sk
|
|
|
|
|
Hi All,
I am having one requirement for user selected color dropout in the image.
My requirement is that suppose user can load one image and select perticular part in the image and then press some button so my whole image should dropout that color from whole image.
can any body guide me how to do that?
montu3377
|
|
|
|
|
Hi!
What do you mean with "dropout"?
Each pixel with the selected color will be made transparent? Assigned a different color?
The class Bitmap has the two methods GetPixel() and SetPixel() you can use.
This will be quite slow, though.
There was a discussion on fast image processing not so long ago. Try searching the C# forum, you should find some helpful links and approaches.
Regards,
mav
|
|
|
|
|
Hi,
Yeah dropout means color filtering.I had successsfully filtered out the color from the whole image and it takes only 1 second so i am thankful to you.
Now another requirement is that i have to filter the color as per user selected area.
like
here i am describing whole:
when user select a particular area by rectangle then my function should filter(dropout) that color from whole image.
This is my requirement,Now can u tell me how to do that ?
|
|
|
|
|
When the user selects a rectangular area, there can be several colors included. Do you want to filter all these colors?
mav
|
|
|
|
|
Yeah.You understood my point.
I have to filter all these colors,so by that i am providing user facility according to his selected color filtered from the image.
what is now to do?
|
|
|
|
|
Hi,
Yeh Actually when user select one rectangle area then i am planning to take the Averange R,Average G and Average B value and after storing all the value in some object ,i can compare with all pixels and remove color which are related to Averange R,Average G and Average B,so can you tell me is that logic work for filtering the image in user selected color filteration?
can you pls tell me is that work out?
|
|
|
|