Home » BizTalk Server

Dividing an image into WxW blocks using OpenCV

how to divide an image

1 Answer Found


Answer 1

The C++ language is a coding convention, it has no feature for image  processing. Search "OpenCV community" in your favorite search engine to find a forum that is related to OpenCV instead.

The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
Visual C++ MVP



can anyone please tell us hw to read and divide the image into 8X8 blocks...and v explicitly need the code in c language..

thank u


I am facing the problem: Try Catch block is not work that try block failed but catch block is not excuted.

In my case, I tried to excuted the sql like below:

begin try

update [table] set [column] = abc

end try

begin catch
 select 'catch error'
end catch


The [column] is numeric format, but data set to it is not valid number.

When excute this sql, the following error prompt out:

Invalid column name 'abc'.

And the catch block has not been excuted.


I want to know what happen in this case.

Moreover, I found an article talks about the similar case too:



Is there any solution so that I can catch the error without stopping the batch?

Thanks a lot.



My final year project is on iris recognition. My code is supposed to display an image of an iris from file and then use circle finder to detect the edges around the iris and the pupil. However, i keep getting errors and am remaining with two weeks til the deadline. Any help?





#define cvDrawCircle cvCircle

#include "cv.h" //main OpenCV functions

#include "highgui.h" //OpenCV GUI functions¯include <stdio.h>

#include "cxcore.h"

#include "cvaux.h"

#include "cvcam.h"

int main()


/* declare a new IplImage pointer, the basic

image data structure in OpenCV */

IplImage* newImg;

/* load an image named "0001.pgm", 1 means

this is a color image */

newImg = cvLoadImage("0001.pgm",1);

//create a new window

cvNamedWindow("Window", 1);


//display the image in the window

cvShowImage("Window", newImg);

/* Finds circles in the image */

CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage,

int method, double dp, double min_dist,

double param1 CV_DEFAULT(100),

double param2 CV_DEFAULT(100),

int min_radius CV_DEFAULT(0),

int max_radius CV_DEFAULT(0));

//wait for key to close the window


cvDestroyWindow( "Window" ); //destroy the window

cvReleaseImage( &newImg ); //release the memory for the image

return 0;


--------------------Configuration: IrisRecognition - Win32 Debug--------------------



c:\program files\microsoft visual studio\myprojects\irisrecognition\irisrecognition.c(39) : error C2275: 'CvSeq' : illegal use of this type as an expression

c:\program files\opencv\cxcore\include\cxtypes.h(1219) : see declaration of 'CvSeq'

c:\program files\microsoft visual studio\myprojects\irisrecognition\irisrecognition.c(39) : error C2059: syntax error : '__cdecl'

Error executing cl.exe.

IrisRecognition.obj - 2 error(s), 0 warning(s)

am using microsoft Visual C++ 2006



Hi, this might be a silly question, but I need to know if for the code below, if i can extract the cvCaptureFromCAM() function from the highgui.lib and paste it in my code so that I can rename it to camcapture() and then call that within my program without just including the highgui library file at the beginning of the code file:

CvCapture* pCapture =0;

//Initialize video capture
= cvCaptureFromCAM( CV_CAP_ANY );


Many Thanks





Hi i'm trying to use opencv in vc8 express, but all of the programs that i've coded crashed and all of them gave some output like this:

1>------ Build started: Project: aman, Configuration: Debug Win32 ------


1>amnn.obj : error LNK2019: unresolved external symbol _cvDestroyWindow referenced in function _wmain

1>amnn.obj : error LNK2019: unresolved external symbol _cvReleaseCapture referenced in function _wmain

1>amnn.obj : error LNK2019: unresolved external symbol _cvCopy referenced in function _wmain

1>amnn.obj : error LNK2019: unresolved external symbol _cvCreateImage referenced in function _wmain

1>amnn.obj : error LNK2019: unresolved external symbol _cvGetSize referenced in function _wmain

1>amnn.obj : error LNK2019: unresolved external symbol _cvQueryFrame referenced in function _wmain

1>amnn.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _wmain

1>amnn.obj : error LNK2019: unresolved external symbol _cvCaptureFromCAM referenced in function _wmain

1>C:\Documents and Settings\acer\Belgelerim\Visual Studio 2005\Projects\aman\Debug\aman.exe : fatal error LNK1120: 8 unresolved externals

1>Build log was saved at "file://c:\Documents and Settings\acer\Belgelerim\Visual Studio 2005\Projects\aman\aman\Debug\BuildLog.htm"

1>aman - 9 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I've included correct headers and set VC++ directions properly and I guess it's some kind of setting linker input but i don2t know how to do it in this version :(. Looking forward for your help



Hello everyone,

I installed opencv successfully just now , and now I am learning about it.

Does anyone know how to connect the PC to camera by using Opencv ?

any help would be appreciated .

Thank you 




Package has been updated to provide x64 complementary elements.

Happy New Year 2011


Hi all. I'm trying to use c code with opencv in face detection and counting, but I cannot build the source. I am trying to compile my project and I am having a lot of problems with a line in the xutility file.

the error message show that it error with xutility file.

Please help me, how to solve this problem?


Every so often, queries are being blocked by a call to a stored procedure, which is being executed from Excel. There is no deadlock, so the blocked query hangs indefinitely.

From what I've read, ASYNC_NETWORK_IO means that the client is not reading data off the network fast enough. What I don't understand though, is why this would block other processes.

I would expect that when a client makes a call to the database, the database engine runs the query, gets the result set, and then release any locks before sending the resultset to the client.

I find it hard to believe that a single slow client could lock tables in the database.

Is this true?

There are two parts to my question.

How can you assure that slow clients don't block other callers when they cause ASYNC_NETWORK_IO issues?

The second question is if other people have seen this issue when Excel is a client to SQL Server 2005 using automatically refreshing queries (i.e. you set up excel so that it refreshes on some timely basis)



1.I try below code, why do I get all blobs(including committedBlobs which upload by Put Block and Put Block List) except UncommittedBlobs (do not call Put Block List),

protected void GetBlobsWithRequestOptions(String containerName)
 CloudStorageAccount cloudStorageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
 CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();

 CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(containerName);

 BlobRequestOptions blobRequestOptions = new BlobRequestOptions();
 blobRequestOptions.UseFlatBlobListing = true;
 blobRequestOptions.BlobListingDetails = BlobListingDetails.UncommittedBlobs;

 IEnumerable<IListBlobItem> blobList = cloudBlobContainer.ListBlobs(blobRequestOptions);
 foreach (var item in blobList)
  var uri = item.Uri;

2. If I call Put Block and don't call Put Block List (when putting blocks, but net interrupted), and I call Put Block or Put Block List again after a week later, what exception I will get?


I have a validation helper method


I read the documentation and decorated this with the [ContractArgumentValidator] and after the throw statement added the Contract.EndContractBlock() method.

However, I was trying to write out some xml files and I started with a stream via


using (stream sw = ...)
  XmlWriterSettings settings = new XmlWriterSettings {...}
  XmlWriter xml_writer =XmlWriter.Create(sw, settings);



Code Contracts wasn't happy until I checked sw and settings were not null. My preferred method would be to call ThrowIfNull() but when I do I get the "Contract section within try block." compiler error. How am I supposed to make this work?



Using the Task Usage view I'm trying to customize the Cost10 field with a formula that divides Cost by Work to obtain the hourly rate.  When I try this I get an incorrect result, in fact it's not even close.  The results are identical on both Project Server & .mpp.  For example $12,928 / 96 hours is returning $2.24 / hr instead of $134.67.

The mpp file is Project Professioal 2003 SP3


I'm a newbie with sql, here is my problem:

How do I select specific rows from a field (column), sum and divide the rows selected.

To be specific I want to add the rows that are 60 30 20 and 10 up from the last record and divide by 4,

Thanks for any help provided.



I  have this expression for Growth in a matrix and keep getting the Dreaded NAN and infinity when zeros are present , how would i get rid of that?


=(SUM(IIF(RIGHT(Fields!Year.Value,4)= YEAR(NOW),CDBL(Fields!PL_Gross_Sales_Amt.Value),CDBl(0))) - SUM(IIF(RIGHT(Fields!Year.Value,4)= YEAR(NOW)-1, Fields!PL_Gross_Sales_Amt.Value, nothing)) ) / SUM(IIF(RIGHT(Fields!Year.Value,4)= YEAR(NOW)-1, CDBL(Fields!PL_Gross_Sales_Amt.Value),CDBl(0)))


ok so the calculation i'm trying to produce is something like (a/b) - 1 and i need to know how to get this so when b = 0 the entire value printed out is just a blank or NULL value. So this is what i have so far:



(casewhen (MonthPosted = @2PrevMonth AND m.billedamount = 0)then' 'elseSUM(casewhen MonthPosted = @PrevMonth then m.billedamount end) /NULLIF(SUM(casewhen MonthPosted = @2PrevMonth then m.billedamount end),0)- 1)as'Billed Amount'



#MOM m

So basically what i need is that code to execute if b does not equal 0 and then a blank or null to print otherwise. So this is the code i wrote up, but i'm getting an error.

Msg 102, Level 15, State 1, Line 148

Incorrect syntax near ')'

any help would be great! thanks!


I'm not sure if this isn't more of a discussion thread than a question thread.

I am making a designer/sketch tool, and I want to divide up the logics of selection, selection/multi-selection drag, drag-to-pan, drag and drop, zoom, etc.

In previous projects, I had a switch statement to handle a lot of this, but this time there are a lot more features, so I really want to keep this clean.

Currently, I have an interface "IDesignerLogic". I have a class "PanAndZoomLogic : IDesignerLogic", "SketchLogic : IDesignerLogic", and I'm in the process of creating a SelectionLogic and a DragLogic. Then, based on the mode ("tool selected"), I lode the appropriate class that will handle the events raised.

I'm a little worried that I will either have some code redundancy, or I won't separate my actions correctly.

I'm asking for advice on how people divide up the responsibilities. Maybe there is a systematic way of looking at this problem that, through perserverance, I will generate the appropriate design pattern.


Also, I didn't go with an InkCanvas for my designer. Instead I went with a Canvas, and I'm thinking I should use an adorner for my selection box.

Any thoughts?




Our sharepoint has for the past two days in a row become unavailable to users.  It seems to occur with something related to the Office Server Search.  Any help appreciated.

Here is an error that has just posted in the event viewer:

Event Type: Error
Event Source: Office Server Search
Event Category: Gatherer
Event ID: 10036
Date: 8/19/2010
Time: 7:05:19 AM
User: N/A
Computer: THOR-095
A database error occurred.

Source: Microsoft OLE DB Provider for SQL Server
Code: 15070 occurred 1 time(s)
Description: Object 'dbo.membership_updateRecursiveMemberships' was successfully marked for recompilation.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


A very little, though annoying problem.

My awful code:


int here = herea / 100 * per;


It should calculate 'per' % from the variabele 'herea'.

If herea is 100 and per 10; 10 is returned. That's right.

Though if the number is 90, and I take 10 'per' from that, I get 90 returned!

That's not right. I messed around with decimals, without any signal of success.. I guess the problem is at the division by 100, as integers don't take decimals.



~ Eggmaker


Hi there,

I have a problem that I cannot seem to resolve. We are using an access database to store data from a Quality Assurance Tool. I need to calculate an average on a specific column in the table, however the SQL statement needs to count the number of records that contain "0.1" and divide it by the total number of records in the table. This data is then displayed in an ASP Page.

The field name is 1.

Here is the SQL:

StrSQL =  "(Select Count([1]) FROM cservice Where [1]=0.1) / (Select Count([1]) FROM cservice) As questaverage "

Help would be much appriciated!





I have been trying to figure this out all day.. i have a project due tomorrow at 9:30am, am new to c++ but got some things down. My question is i am assigned to divide and integer by 2 to get its half , when i divide an odd number by 2 for instance 3/2 i get 1, whereas we know it suppose to be 1.50, Ive done all the research i read into modulus and etc, i just dont know how to code it do that if i divide any integer by 2 it give me the remainder. well here is my project



CS140 21746

Name: X

Project 1

Input: any integer number from the keyboard

Output: half the number that wa sinput on the screen

Program description: This program prints half of the number input by the user.

Formula: input number/2

File Names: Project1.cpp, outla.txt, out1b.txt


#include <iostream>

using namespace std;

int main()


int number;//number to be input by user

int total; //half the number input

//Output the program purpose


//Prompt for the number

cout<< "Please enter an integer number ";

cin>> number;//Input a number

total = number%2;

//Divide the number by 2 using integer division



//Display half the input number

cout<< total << " is half the number you typed.\n\n";

//Display your own message that tells something about you.

cout << "My name is X, and i am majoring in Computer Science\n";

cout << "Thank you for using this program i hope it was useful\n\n";


//Display my name

cout << "Programmer:X\n";

return 0;



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure