# C# Video into Binary problem

• (2 Pages)
• 1
• 2

## 18 Replies - 3563 Views - Last Post: 22 July 2011 - 02:36 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=221993&amp;s=d79460855e19eb45d70665845e5a0446&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #16 ZenQ

• New D.I.C Head

Reputation: 1
• Posts: 14
• Joined: 22-February 11

## Re: C# Video into Binary problem

Posted 24 March 2011 - 04:09 AM

```        private void calculate(Bitmap bimg)
{
int boundA = 120;
int boundB = 80;
int initi = 0;
int initj = 0;

for (int s = 0; s < 6; s++)
{
for (int i = initi; i < boundA; i++)
{
for (int j = initj; j < boundB; j++)
{
string b = bimg.GetPixel(i, j).B.ToString();
string g = bimg.GetPixel(i, j).B.ToString();
string r = bimg.GetPixel(i, j).B.ToString();
if (b.ToString() == "255" && g.ToString() == "255" && r.ToString() == "255")
{
int tmp = pixCompare[i,j];
if (tmp == 0)
{
differentCount[s] += 1;
pixCompare[i,j] = 1;
}
}
else
{
int tmp = pixCompare[i,j];
if (tmp == 1)
{
differentCount[s] += 1;
pixCompare[i,j] = 0;
}
}
}
}
if (differentCount[s] > 100)
inputNeuron[s] = 1;
else
inputNeuron[s] = 0;

if (boundB < 320)
{
if (boundA < 240)
{
boundB += 80;
initj += 80;
}
else
{
boundB += 80;
initj += 80;
}

}
else
{
if (boundA < 240)
{
boundA += 120;
boundB = 80;
initi += 120;
initj = 0;
}
}
}
}
```

This is the code for segment comparison that I did.
The video has:
320px width
240px height

the first iteration (s) is for each segments( I am using 4x2 = 8 segments)
the second iteration (i) is for height
the third iteration (j) is for width

I received an exception "Object is currently in use elsewhere." at line "string b = bimg.GetPixel(i, j).B.ToString();"

Was This Post Helpful? 0

### #17 ZenQ

• New D.I.C Head

Reputation: 1
• Posts: 14
• Joined: 22-February 11

## Re: C# Video into Binary problem

Posted 24 March 2011 - 05:32 AM

Where is the edit button? :S

sorry I fixed that problem..But now I have a new problem.
I tried displaying the contents of the inputNeuron Array, but all I get is 0..
Which would mean my loop have mistakes?
```if (differentCount[s] > 100)
inputNeuron[s] = 1;
else
inputNeuron[s] = 0;

```

I declared the arrays like so:

```public int[,] pixCompare = new int[10000, 10000];
public int[] differentCount = new int[8];
public int[] inputNeuron = new int[8];
```

Was This Post Helpful? 0

### #18 williamjacob

• New D.I.C Head

Reputation: 0
• Posts: 1
• Joined: 21-July 11

## Re: C# Video into Binary problem

Posted 21 July 2011 - 10:56 PM

Thanks for this post... helped me a lot..

______________
UK education in India
Was This Post Helpful? 0

### #19 ragingben

• D.I.C Addict

Reputation: 164
• Posts: 612
• Joined: 07-October 08

## Re: C# Video into Binary problem

Posted 22 July 2011 - 02:36 AM

I love the fact that you joined D.I.C to thank someone for a thread that hasn't been updated for 4 months, especially when the thread itself never reached a sucsessful conclusion!

This post has been edited by ragingben: 22 July 2011 - 02:37 AM

Was This Post Helpful? 0

• (2 Pages)
• 1
• 2

 Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).