Search Results

Search found 15535 results on 622 pages for 'mat keep'.

Page 18/622 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • How to change by using CVGrayscaleMat

    - by Babul
    With the following code the image showed as above is converted as below image... Their it's showing black background with gray lines.....i want white background with gray lines .. Please guide me .. i am new to iPhone Thanks alot in Advance - (void)viewDidLoad { [super viewDidLoad]; // Initialise video capture - only supported on iOS device NOT simulator #if TARGET_IPHONE_SIMULATOR NSLog(@"Video capture is not supported in the simulator"); #else _videoCapture = new cv::VideoCapture; if (!_videoCapture->open(CV_CAP_AVFOUNDATION)) { NSLog(@"Failed to open video camera"); } #endif // Load a test image and demonstrate conversion between UIImage and cv::Mat UIImage *testImage = [UIImage imageNamed:@"testimage.jpg"]; double t; int times = 10; //-------------------------------- // Convert from UIImage to cv::Mat NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; t = (double)cv::getTickCount(); for (int i = 0; i < times; i++) { cv::Mat tempMat = [testImage CVMat]; } t = 1000 * ((double)cv::getTickCount() - t) / cv::getTickFrequency() / times; [pool release]; NSLog(@"UIImage to cv::Mat: %gms", t); //------------------------------------------ // Convert from UIImage to grayscale cv::Mat pool = [[NSAutoreleasePool alloc] init]; t = (double)cv::getTickCount(); for (int i = 0; i < times; i++) { cv::Mat tempMat = [testImage CVGrayscaleMat]; } t = 1000 * ((double)cv::getTickCount() - t) / cv::getTickFrequency() / times; [pool release]; NSLog(@"UIImage to grayscale cv::Mat: %gms", t); //-------------------------------- // Convert from cv::Mat to UIImage cv::Mat testMat = [testImage CVMat]; t = (double)cv::getTickCount(); for (int i = 0; i < times; i++) { UIImage *tempImage = [[UIImage alloc] initWithCVMat:testMat]; [tempImage release]; } t = 1000 * ((double)cv::getTickCount() - t) / cv::getTickFrequency() / times; NSLog(@"cv::Mat to UIImage: %gms", t); // Process test image and force update of UI _lastFrame = testMat; [self sliderChanged:nil]; } - (IBAction)capture:(id)sender { if (_videoCapture && _videoCapture->grab()) { (*_videoCapture) >> _lastFrame; [self processFrame]; } else { NSLog(@"Failed to grab frame"); } } - (void)processFrame { double t = (double)cv::getTickCount(); cv::Mat grayFrame, output; // Convert captured frame to grayscale cv::cvtColor(_lastFrame, grayFrame, cv::COLOR_RGB2GRAY); // Perform Canny edge detection using slide values for thresholds cv::Canny(grayFrame, output, _lowSlider.value * kCannyAperture * kCannyAperture, _highSlider.value * kCannyAperture * kCannyAperture, kCannyAperture); t = 1000 * ((double)cv::getTickCount() - t) / cv::getTickFrequency(); // Display result self.imageView.image = [UIImage imageWithCVMat:output]; self.elapsedTimeLabel.text = [NSString stringWithFormat:@"%.1fms", t]; }

    Read the article

  • Need help with reCAPTCHA - keep getting incorrect-captcha-sol

    - by Anriëtte Combrink
    Hi I am trying to add a reCAPTCHA to my site, but keep getting incorrect-captcha-sol error when I submit the answer. Can anyone tell me if I am correct in doing the following? I have a generic index.php, which includes contact.php. In contact.php I have inserted the following code: require_once('recaptchalib.php'); $publickey = "XXXX"; $privatekey = "XXXX"; //the response from reCAPTCHA $resp = null; //the error code from reCAPTCHA, if any $error = null; if ($_POST['submit']) { $message = $_POST['message_txt']; $name = $_POST['name_txt']; $email = $_POST['email_txt']; $emailBody = $message; $to = 'xx'; $from = $name.' <'.$email.'>'; $subject = 'XX Website Enquiry'; $headers = 'From: '.$from; $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { echo 'captcha correct'; if (mail($to,$subject,$emailBody,$headers)) { //echo 'mail sent'; $confirmation = 'sent'; } else { //echo 'mail not sent'; $confirmation = 'error'; } } else { # set the error code so that we can display it. You could also use # die ("reCAPTCHA failed"), but using the error message is # more user friendly $error = $resp->error; echo $error; } } In my html I inserted the CAPTCHA like this: <form name="contactForm" method="post" action="index.php?id=contact&action=submit#contact"> <tr><td>Name</td><td><div align="right"> <input type="text" name="name_txt" class="input"> </div></td></tr> <tr><td>Email</td><td><div align="right"> <input type="text" name="email_txt" class="input"> </div></td></tr> <tr><td height="10"></td></tr> <tr><td colspan="2">Message</td></tr> <tr><td colspan="2"><textarea name="message_txt" class="textarea" style="width:200px; height:100px"></textarea></td></tr> <tr><td colspan="2"><?php echo recaptcha_get_html($publickey, $error); ?></td></tr> <tr><td colspan="2" style="padding-top:10px;"><input type="image" src="images/header_06.gif" name="submit" value="submit"></td></tr> </form> I cannot see that I am doing anything wrong, but would appreciate any constructive criticism. TIA

    Read the article

  • How do you keep from running into the same problems over and over?

    - by Stephen Furlani
    I keep running into the same problems. The problem is irrelevant, but the fact that I keep running into is completely frustrating. The problem only happens once every, 3-6 months or so as I stub out a new iteration of the project. I keep a journal every time, but I spend at least a day or two each iteration trying to get the issue resolved. How do you guys keep from making the same mistakes over and over? I've tried a journal but it apparently doesn't work for me. [Edit] A few more details about the issue: Each time I make a new project to hold the files, I import a particular library. The library is a C++ library which imports glew.h and glx.h GLX redefines BOOL and that's not kosher since BOOL is a keyword for ObjC. I had a fix the last time I went through this. I #ifndef the header in the library to exclude GLEW and GLX and everything worked hunky-dory. This time, however, I do the same thing, use the same #ifndef block but now it throws a bunch of errors. I go back to the old project, and it works. New project no-worky. It seems like it does this every time, and my solution to it is new each time for some reason. I know #defines and #includes are one of the trickiest areas of C++ (and cross-language with Objective-C), but I had this working and now it's not.

    Read the article

  • Keep width even when column changes. (HTML)

    - by Andrew
    I have a login on the left sidebar of my website. When a user is logged in, the sidebar width doesn't remain the same as it was when the user wasn't logged in. Is there a way to keep the width the same? <!-- Start Sidebar --> <td id="sidebar" valign="top" height="400px" style="width: 200px"> <!-- Login Form --> <table id="TABLE2"> <tr> <td valign="top"> <asp:LoginView ID="LoginView1" runat="server"> <LoggedInTemplate> <br /> <br /> You are currently logged in. </LoggedInTemplate> <AnonymousTemplate> <asp:Login ID="Login1" runat="server" BorderPadding="0" BorderStyle="None" BorderWidth="0px" Font-Names="Verdana" Font-Size="0.8em" CreateUserText="Sign Up Now!" CreateUserUrl="http://www.tiltonindustries.com/Tilton/Login/CreateAccount.aspx" Height="1px" PasswordRecoveryText="Forgot your password?" PasswordRecoveryUrl="http://www.tiltonindustries.com/Tilton/Login/ForgotPassword.aspx" TextLayout="TextOnTop" Width="200px" DestinationPageUrl="http://www.tiltonindustries.com/Tilton/default.aspx"> <TitleTextStyle Font-Bold="True" Font-Size="0.9em"/> <InstructionTextStyle Font-Italic="True" ForeColor="Black" /> <TextBoxStyle Font-Size="0.8em" /> <LoginButtonStyle BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#990000" /> <LayoutTemplate> <table border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse; height: 159px;"> <tr> <td style="height: 176px; width: 135px;"> <table border="0" cellpadding="0" style="width: 219px; height: 1px" id="TABLE1"> <tr> <td align="center" style="font-weight: bold; font-size: 0.9em; color: white; height: 18px; background-color: #990000; text-align: center" colspan="2"> Log In</td> </tr> <tr> <td style="width: 94px; height: 10px;"> </td> <td style="height: 10px; width: 78px;"> </td> </tr> <tr> <td style="width: 94px; height: 20px; text-align: right"> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label> &nbsp; </td> <td style="height: 20px; text-align: left; width: 78px;"> <asp:TextBox ID="UserName" runat="server" Font-Size="0.9em" EnableViewState="False" Width="100px" MaxLength="20"></asp:TextBox><asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="ctl01$Login1">*</asp:RequiredFieldValidator></td> </tr> <tr> <td style="width: 94px; text-align: right"> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> &nbsp; </td> <td style="text-align: left; width: 78px;"> <asp:TextBox ID="Password" runat="server" Font-Size="0.9em" TextMode="Password" Width="100px"></asp:TextBox><asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="ctl01$Login1">*</asp:RequiredFieldValidator></td> </tr> <tr> <td style="height: 20px; width: 94px;"> &nbsp;</td> <td style="height: 20px; text-align: left; width: 78px;"> <asp:CheckBox ID="chkRememberMe" runat="server" Text="Remember Me" Width="104px" /></td> </tr> <tr> <td align="center" style="color: red; width: 94px; height: 20px;"> </td> <td align="center" style="color: red; text-align: left; width: 78px; height: 20px;"> <asp:Button ID="LoginButton" runat="server" BorderStyle="Solid" BorderWidth="1px" CommandName="Login" Font-Names="Verdana" Font-Size="1.0 em" Text="Log In" ValidationGroup="ctl01$Login1" Width="59px" BackColor="Gray" BorderColor="Black" Height="20px" /></td> </tr> <tr> <td align="center" style="width: 250px; color: red; height: 35px; text-align: center;" colspan="2"> <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal></td> </tr> <tr> <td style="height: 26px; width: 94px;"> <asp:HyperLink ID="CreateUserLink" runat="server" NavigateUrl="http://www.tiltonindustries.com/Tilton/Login/CreateAccount.aspx">Sign Up Now!</asp:HyperLink>&nbsp; </td> <td style="width: 78px; height: 26px"> <asp:HyperLink ID="PasswordRecoveryLink" runat="server" NavigateUrl="http://www.tiltonindustries.com/Tilton/Login/ForgotPassword.aspx">Forgot your password?</asp:HyperLink></td> </tr> </table> </td> </tr> </table> </LayoutTemplate> </asp:Login> </AnonymousTemplate> </asp:LoginView> <!-- End Login Form --> <!-- Quick Links --> <br /> <br /> <p style="font-size: 14px; font-weight: bold; color: White"> Quick Links:<br /> </p> <br /> <p id="quicklinks"> <a href="default.aspx">Home</a><br /> <a href="services.aspx">Services</a><br /> <a href="matching.aspx">Color Matching</a><br /> <a href="packaging.aspx">Custom Packaging</a><br /> <a href="decorals.aspx">Decorals</a><br /> <a href="delivery.aspx">Delivery</a><br /> <a href="items.aspx">Items</a><br /> <a href="msds.aspx">MSDS</a><br /> <a href="plant.aspx">Plant Capabilities</a><br /> <a href="standard.aspx">Standard Colors</a><br /> <a href="special.aspx">Special Effects</a><br /> <a href="coatings.aspx">Spray Coatings</a><br /> <a href="warranty.aspx">Warranty</a><br /> <a href="http://www.tiltonindustries.com/Tilton/Login/Login.aspx">My Account</a><br /> <a href="gallery.aspx">Gallery</a><br /> <a href="about.aspx">About</a><br /> <a href="faq.aspx">F.A.Q</a><br /> <a href="links.aspx">Links</a><br /> <a href="careers.aspx">Careers</a><br /> <a href="contact.aspx">Contact</a><br /> <br /> </p> </td> </tr> </table> </td> <!-- End Sidebar -->

    Read the article

  • What is the best way to keep track of the median?

    - by Steven Mou
    I read a question in one book: Numbers are randomly generated and stored into an (expanding) array, How would you keep track of the median? There are two data structures can solve the problem. One is the balanced binary tree, the other is two heaps which keep trace of the biggest half and the smallest half of the elements. I think these two solutions has the same running time as O(n lg n), but I am not sure of my judgement. In your opinions, What is the best way to keep track of the median?

    Read the article

  • How to keep pyglet from clearing the screen ?

    - by mayasky
    I want to draw a scene and sequentially add lines to it. But pyglet keeps updating without control :( , so all I get is blinks from pyglet.gl import * window=pyglet.window.Window() def drawline(): ... @window.event def on_draw(): drawline() pyglet.app.run() should I change the decorator(if there exist options) or what? Thanks!

    Read the article

  • How to keep asm output from Linux kernel module build

    - by fastmonkeywheels
    I'm working on a Linux kernel module for a 2.6.x kernel and I need to view the assembly output, though it's currently being done as a temporary file an deleted afterwords. I'd like to have the assembly output mixed with my C source file so I can easily trace where my problem lies. This is for an ARMv6 core and apparently objdump doesn't support this architecture. I've included my makefile below. ETREP=/xxSourceTreexx/ GNU_BIN=$(ETREP)/arm-none-linux-gnueabi/bin CROSS_COMPILE := $(GNU_BIN)/arm-none-linux-gnueabi- ARCH := arm KDIR=$(ETREP)/linux-2.6.31/ MAKE= CROSS_COMPILE=$(CROSS_COMPILE) ARCH=$(ARCH) make obj-m += xxfile1xx.o all: $(MAKE) -C $(KDIR) M=$(PWD) modules clean: $(MAKE) -C $(KDIR) M=$(PWD) clean

    Read the article

  • Android: How to keep onItemSelected from firing off on a newly instantiated Spinner

    - by Drennen
    I've thought of some less than elegant ways to solve this, but I know I must be missing something. My onItemSelected fires off immediately without any interaction with the user, and this is undesired behavior. I wish for the UI to wait until the user selects something before it does anything. I even tried setting up the listener in the onResume, hoping that would help, but it doesn't. How can I stop this from firing off before the user can touch the control? THANKS public class CMSHome extends Activity { private Spinner spinner; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Heres my spinner /////////////////////////////////////////// spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( this, R.array.pm_list, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); }; public void onResume() { super.onResume(); spinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); } public class MyOnItemSelectedListener implements OnItemSelectedListener { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { Intent i = new Intent(CMSHome.this, ListProjects.class); i.putExtra("bEmpID", parent.getItemAtPosition(pos).toString()); startActivity(i); Toast.makeText(parent.getContext(), "The pm is " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show(); } public void onNothingSelected(AdapterView parent) { // Do nothing. } } }

    Read the article

  • Keep IIS 7 URL Rewrite module from matching /ScriptResource.axd

    - by D.R. Payne
    I have a website and I have installed URL Rewrite using Web Platform Installer. I wish to allow a user friendly URL like www.foo.com/123456 to go to www.foo.com/page.aspx?blah=123456. Using the User-friendly URL template accomplishes this except that the created rule also matches all of the /scriptresource.axd?blahblah created by ASP.NET which of course breaks most functionality. My initial attempts to exclude the script resource files have failed. The regex generated by the tool is ^([^/]+)/?$

    Read the article

  • Paypal NVP API - Keep getting error 81002

    - by Andree
    Hi there, I am new to PayPal API, and I'm having trouble calling SetExpressCheckout using CURL in PHP. I have set everything correctly, as far as I'm concerned, but I kept getting an 81002 error "Method Specified is not Supported". The code snippet is below. I got the CA Root certificates file from here. <?php $paypal_data = array( 'USER' => urlencode('andree_1272823561_biz_api1.gmail.com'), 'PWD' => urlencode('1272823576'), 'SIGNATURE' => urlencode('Am1t0wiu2tv7VwZ5ebdeY9zv1GF6Ad0PFz-qTGFFf7vbWU6ee4bxy8KL'), 'VERSION' => urlencode('52.0'), 'PAYMENTACTION' => urlencode('Sale'), 'METHOD' => urlencode('SetExpressCheckout'), 'AMT' => urlencode('52.00'), 'RETURNURL' => urlencode('get_express_checkout_details.php'), 'CANCELURL' => urlencode('index.php') ); $url = 'https://api-3t.sandbox.paypal.com/nvp?' . http_build_query($paypal_data); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); $result = curl_exec($curl); curl_close($curl); parse_str($result, $result); ?> <pre>Data sent: <?php print_r($paypal_data); ?></pre> <pre>Result: <?php print_r($result); ?></pre> When I run the code, the output is the following: Data sent: Array ( [USER] => andree_1272823561_biz_api1.gmail.com [PWD] => 1272823576 [SIGNATURE] => Am1t0wiu2tv7VwZ5ebdeY9zv1GF6Ad0PFz-qTGFFf7vbWU6ee4bxy8KL [VERSION] => 52.0 [PAYMENTACTION] => Sale [METHOD] => SetExpressCheckout [AMT] => 52.00 [RETURNURL] => get_express_checkout_details.php [CANCELURL] => index.php ) Result: Array ( [ACK] => Failure [L_ERRORCODE0] => 81002 [L_SHORTMESSAGE0] => Unspecified Method [L_LONGMESSAGE0] => Method Specified is not Supported [L_SEVERITYCODE0] => Error ) Anyone knows what could be the problem? Regards, Andree.

    Read the article

  • How do you keep your business rules DRY?

    - by Mario
    I periodically ponder how to best design an application whose every business rule exists in just a single location. (While I know there is no proverbial “best way” and that designs are situational, people must have a leaning toward one practice or another.) I work for a shop where they prefer to house as much of the business rules as possible in the database. This requires developers in many cases to perform identical front-end validations to avoid sending data to the database that will result in an exception—not very DRY. It grates me anytime I find myself duplicating any kind of logic—even lowly validation logic. I am a single-point-of-truth purist to an anal degree. On the other end of the spectrum, I know of shops that create dumb databases (the Rails community leans in this direction) and handle all of the business logic in a separate tier (in Rails the models would house “most” of this). Note the word “most” which implies that some business logic does end up spilling into other places (in Rails it might spill over into the controllers). In way, a clean separation of concerns where all business logic exists in a single core location is a Utopian fantasy that’s hard to uphold (n-tiered architecture or not). Furthermore, is see the “Database as a fortress” and would agree that it should be built on constraints that cause it to reject bad data. As such, I hold principles that cause a degree of angst as I attempt to balance them. How do you balance the database-as-a-fortress view with the desire to have a single-point-of-truth?

    Read the article

  • Umbraco CMS - keep getting logged out in ie, safari, chrome but not ff

    - by Daniel Horn
    I have a few Umbraco sites running on my server - but i'm getting logged out when using everything else than Firefox when using umbraco. I'm able to log in and after 10-15 sec's i'm being automatically logged out again. How can that be and how do i fix it? :( It's a win 2008 server using MSSQL database and umbraco 4.0.3 btw is running on integrated app pool and .net version 2.0.50727

    Read the article

  • I keep getting a "System InvalidOperationException occurred in System Windows Forms dll" error in VB

    - by Heartrent
    I've just started learning VB.NET with VS 9.0; a small application I'm working on keeps returning an "A first chance exception of type System InvalidOperationException occurred in System Windows Forms dll" error from the Immediate Window. The application has almost zero functionality so far, it consists of a menu strip with: File About |Open |Save |Save As |Quit The only code I have written opens an Open File dialog, a Save As dialog, an About window with background sound and an OK button, and the Quit button which exits. Since there is almost no code for me to search through, I can't understand why there would be an error. The program runs just fine when I'm debugging it too.

    Read the article

  • I keep on getting "save operation failure" after any change on my XCode Data Model

    - by Philip Schoch
    I started using Core Data for iPhone development. I started out by creating a very simple entity (called Evaluation) with just one string property (called evaluationTopic). I had following code for inserting a fresh string: - (void)insertNewObject { // Create a new instance of the entity managed by the fetched results controller. NSManagedObjectContext *context = [fetchedResultsController managedObjectContext]; NSEntityDescription *entity = [[fetchedResultsController fetchRequest] entity]; NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context]; // If appropriate, configure the new managed object. [newManagedObject setValue:@"My Repeating String" forKey:@"evaluationTopic"]; // Save the context. NSError *error; if (![context save:&error]) { // Handle the error... } [self.tableView reloadData]; } This worked perfectly fine and by pushing the +button a new "My Repeating String" would be added to the table view and be in persistent store. I then pressed "Design - Add Model Version" in XCode. I added three entities to the existing entity and also added new properties to the existing "Evaluation" entity. Then, I created new files off the entities by pressing "File - New File - Managed Object Classes" and created a new .h and .m file for my four entities, including the "Evaluation" entity with Evaluation.h and Evaluation.m. Now I changed the model version by setting "Design - Data Model - Set Current Version". After having done all this, I changed my insertMethod: - (void)insertNewObject { // Create a new instance of the entity managed by the fetched results controller. NSManagedObjectContext *context = [fetchedResultsController managedObjectContext]; NSEntityDescription *entity = [[fetchedResultsController fetchRequest] entity]; Evaluation *evaluation = (Evaluation *) [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context]; // If appropriate, configure the new managed object. [evaluation setValue:@"My even new string" forKey:@"evaluationSpeechTopic"]; // Save the context. NSError *error; if (![context save:&error]) { // Handle the error... } [self.tableView reloadData]; } This does not work though! Every time I want to add a row the simulator crashes and I get the following: "NSInternalInconsistencyException', reason: 'This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.'" I had this error before I knew about creating new version after changing anything on the datamodel, but why is this still coming up? Do I need to do any mapping (even though I just added entities and properties that did not exist before?). In the Apple Dev tutorial it sounds very easy but I have been struggling with this for long time, never worked after changing model version.

    Read the article

  • Python bindings for C++ code using OpenCV giving segmentation fault

    - by lightalchemist
    I'm trying to write a python wrapper for some C++ code that make use of OpenCV but I'm having difficulties returning the result, which is a OpenCV C++ Mat object, to the python interpreter. I've looked at OpenCV's source and found the file cv2.cpp which has conversions functions to perform conversions to and fro between PyObject* and OpenCV's Mat. I made use of those conversions functions but got a segmentation fault when I tried to use them. I basically need some suggestions/sample code/online references on how to interface python and C++ code that make use of OpenCV, specifically with the ability to return OpenCV's C++ Mat to the python interpreter or perhaps suggestions on how/where to start investigating the cause of the segmentation fault. Currently I'm using Boost Python to wrap the code. Thanks in advance to any replies. The relevant code: // This is the function that is giving the segmentation fault. PyObject* ABC::doSomething(PyObject* image) { Mat m; pyopencv_to(image, m); // This line gives segmentation fault. // Some code to create cppObj from CPP library that uses OpenCV cv::Mat processedImage = cppObj->align(m); return pyopencv_from(processedImage); } The conversion functions taken from OpenCV's source follows. The conversion code gives segmentation fault at the commented line with "if (!PyArray_Check(o)) ...". static int pyopencv_to(const PyObject* o, Mat& m, const char* name = "<unknown>", bool allowND=true) { if(!o || o == Py_None) { if( !m.data ) m.allocator = &g_numpyAllocator; return true; } if( !PyArray_Check(o) ) // Segmentation fault inside PyArray_Check(o) { failmsg("%s is not a numpy array", name); return false; } int typenum = PyArray_TYPE(o); int type = typenum == NPY_UBYTE ? CV_8U : typenum == NPY_BYTE ? CV_8S : typenum == NPY_USHORT ? CV_16U : typenum == NPY_SHORT ? CV_16S : typenum == NPY_INT || typenum == NPY_LONG ? CV_32S : typenum == NPY_FLOAT ? CV_32F : typenum == NPY_DOUBLE ? CV_64F : -1; if( type < 0 ) { failmsg("%s data type = %d is not supported", name, typenum); return false; } int ndims = PyArray_NDIM(o); if(ndims >= CV_MAX_DIM) { failmsg("%s dimensionality (=%d) is too high", name, ndims); return false; } int size[CV_MAX_DIM+1]; size_t step[CV_MAX_DIM+1], elemsize = CV_ELEM_SIZE1(type); const npy_intp* _sizes = PyArray_DIMS(o); const npy_intp* _strides = PyArray_STRIDES(o); bool transposed = false; for(int i = 0; i < ndims; i++) { size[i] = (int)_sizes[i]; step[i] = (size_t)_strides[i]; } if( ndims == 0 || step[ndims-1] > elemsize ) { size[ndims] = 1; step[ndims] = elemsize; ndims++; } if( ndims >= 2 && step[0] < step[1] ) { std::swap(size[0], size[1]); std::swap(step[0], step[1]); transposed = true; } if( ndims == 3 && size[2] <= CV_CN_MAX && step[1] == elemsize*size[2] ) { ndims--; type |= CV_MAKETYPE(0, size[2]); } if( ndims > 2 && !allowND ) { failmsg("%s has more than 2 dimensions", name); return false; } m = Mat(ndims, size, type, PyArray_DATA(o), step); if( m.data ) { m.refcount = refcountFromPyObject(o); m.addref(); // protect the original numpy array from deallocation // (since Mat destructor will decrement the reference counter) }; m.allocator = &g_numpyAllocator; if( transposed ) { Mat tmp; tmp.allocator = &g_numpyAllocator; transpose(m, tmp); m = tmp; } return true; } static PyObject* pyopencv_from(const Mat& m) { if( !m.data ) Py_RETURN_NONE; Mat temp, *p = (Mat*)&m; if(!p->refcount || p->allocator != &g_numpyAllocator) { temp.allocator = &g_numpyAllocator; m.copyTo(temp); p = &temp; } p->addref(); return pyObjectFromRefcount(p->refcount); } My python test program: import pysomemodule # My python wrapped library. import cv2 def main(): myobj = pysomemodule.ABC("faces.train") # Create python object. This works. image = cv2.imread('61.jpg') processedImage = myobj.doSomething(image) cv2.imshow("test", processedImage) cv2.waitKey() if __name__ == "__main__": main()

    Read the article

  • How to make ASP.Net MVC checkboxes keep state

    - by myotherme
    I have the following situation: I have a class Product that can have a confirmation from various Stations. So I have a ViewModel that holds the Product information, and a list of stations, and all the ProductStationConfirmations. public class ProductViewModel { public Product Product { get; private set; } public List<Station> Stations { get; private set; } public Dictionary<string, ProductStationConfirmation> ProductStationConfirmations { get; private set; } public ProductViewModel(int productID) { // Loads everything from DB } } In my partial view for inserting/editing I iterate over the stations to make a checkbox for each of them: <div class="editor-label"> <%= Html.LabelFor(model => model.Product.Title)%> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Product.Title)%> <%= Html.ValidationMessageFor(model => model.Product.Title)%> </div> <fieldset> <legend>Station Confirmations</legend> <% foreach (var station in Model.Stations) { %> <div class="nexttoeachother"> <div> <%= Html.Encode(station.Name) %> </div> <div> <%= Html.CheckBox("confirm_"+station.ID.ToString(), Request["confirm_"+station.ID.ToString()] == null ? Model.ProductStationConfirmations.ContainsKey(Entities.ProductStationConfirmation.MakeHash(Model.Product.ID, station.ID)) : Request["confirm_" + station.ID.ToString()].Contains("true") ) %> </div> </div> <% } %> </fieldset> This works and I can process the Request values to store the confirmed Stations, but it is really messy. I made it this way to preserve the state of the checkboxes between round trips if there is a problem with the model (missing title, bad value for decimal, or something that can only be checked server-side like duplicate tile). I would expect that there is a nicer way to do this, I just don't know what it is. I suspect that I need to change the shape of my ViewModel to better accommodate the data, but i don't know how. I am using MVC 2.

    Read the article

  • C# UTF8 output keep encoded characters intact

    - by Stefan Pohl
    Hello, i have a very simple question I can't seem to get my head around. I have a properly encoded UTF8-String I parse into a JObject with Json.NET, fiddle around with some values and write it to the commandline, keeping the encoded characters intact. Everything works great except for the keeping the encoded characters intact part. Code: var json = "{roster: [[\"Tulg\u00f4r\", 990, 1055]]}"; var j = JObject.Parse(json); for (int i = 0; i < j["roster"].Count(); i++) { j["roster"][i][1] = ((int)j["roster"][i][1]) * 3; j["roster"][i][2] = ((int)j["roster"][i][2]) * 3; } Console.WriteLine(JsonConvert.SerializeObject(j, Formatting.None)); Actual Output: {"roster":[["Tulgôr",2970,3165]]} Desired Output: {"roster":[["Tulg\u00f4r",2970,3165]]} It seems like my phrasing in Google is inappropriate since nothing useful came up. I'm sure it's something uber-easy and i will feel pretty stupid afterwards. :)

    Read the article

  • How to keep character encoding with database queries.

    - by JasonS
    Hi, I am doing the following. 1) I am exporting a database and saving it to a file called dump.sql. 2) The file is then transferred to a different server via PHP ftp. 3) When the file has been successfully transferred the administrator has an option to run a 'dbtransfer' script on the new host. 4) This script blows up the script and runs the queries line by line. This works great - however there is a problem with foreign language encoding. We are using UTF-8. Step 1 : This works fine, file is in UTF-8 Format. Step 3 : When I test the contents of the dump.sql file using mb_check_encoding(). The string comes back as UTF-8. Step 4 : This creates tables with utf8_general_ci encoding. The information is dumped in. When I check the table after the transfer I get records like this: 'ç,Ç,ö,Ö,ü,Ü,ı,İ,ş,Ş,ğ,Ğ'. I don't understand how a UTF-8 string can lose its encoding when it goes into the database. Am I missing a step? Do I need to run some sort of function to ensure the string is parsed as UTF-8? Once the system is installed I can save foreign language queries. It is just the transfer that is messing up. Any ideas?

    Read the article

  • Superfish: How to keep sub menu open after it has been clicked

    - by Roland
    I'm having the following scenario. I have a menu and if one hovers over the menu a sub menu appears and if mouse moves out the sub menu disappears, now I want the following if I click on the on a item in the sub menu, I want the sub-menu to remain open, when the new page has been loaded. I'm using superfish Jquery plugin for this. Is this possible and if how. my code in html <div id="nav"> <div id="nav2"> <ul class="sf-menu sf-navbar "> <li> <a title="HOME" class="sf-with-ul " href="/index.php?r=site/index&amp;sid=1">HOME</a> </li> </ul> <ul class="sf-menu sf-navbar"> <li> <a href="?sid=2" id="gallery" class="sf-with-ul selected_main">GALLERY</a> <ul class="subs" id="sub1"><li class="arrow"><img src="images/arrow.gif" /></li><li><a title="Kitchens" href="/index.php?r=images/sddsd&amp;id=1">Kitchens</a></li><li><a title="Vanities" href="/index.php?r=images/sddsd&amp;id=2">Vanities</a></li></ul> </li> </ul> <ul class="sf-menu sf-navbar "> <li> <a href="?sid=3" class="sf-with-ul " >ACCESSORIES</a> <ul class="subs" id=""><li class="arrow"><img src="images/arrow.gif" /></li><li><a title="Door Handles" href="/index.php?r=images/sddsd&amp;id=2">Door Handles</a></li><li><a title="Spanners" href="/index.php?r=images/sddsd&amp;id=1">Spanners</a></li></ul> </li> </ul> <ul class="sf-menu sf-navbar "> <li> <a title="CONTACT US" class="sf-with-ul " href="/index.php?r=site/contact&amp;sid=4">CONTACT US</a> </li> </ul> </div> </div> and then the superfish code $(function(){ $("ul.sf-menu").superfish({ delay: 0, speed: 'fast', autoArrows: false, dropShadows: false }); }); I've also noticed that the following css code is used to display the item left: 0; top: 2.5em; z-index: 99;

    Read the article

  • Trying to include a library, but keep getting 'undefined reference to' messages

    - by KU1
    I am attempting to use the libtommath library. I'm using the NetBeans IDE for my project on Ubuntu linux. I have downloaded and built the library, I have done a 'make install' to put the resulting .a file into /usr/lib/ and the .h files into /usr/include It appears to be finding the files appropriately (since I no longer get those errors, which I did before installing into the /usr directories). However, when I create a simple main making a call to mp_init (which is in the library), I get the following error when I attempt to make my project: mkdir -p build/Debug/GNU-Linux-x86 rm -f build/Debug/GNU-Linux-x86/main.o.d gcc -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.c mkdir -p dist/Debug/GNU-Linux-x86 gcc -o dist/Debug/GNU-Linux-x86/cproj1 build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/main.o: In function 'main': /home/[[myusername]]/NetBeansProjects/CProj1/main.c:18: undefined reference to `mp_init' collect2: ld returned 1 exit status make[2]: *** [dist/Debug/GNU-Linux-x86/cproj1] Error 1 So, it looks like the linker can't find the function within the library, however it IS there, so I just don't know what could be causing this. Any help would be appreciated. I get the same error if I type the gcc command directly and skip the makefile, I also made sure the static library got compiled with gcc as well. Edited to Add: I get these same errors if I do the compile directly and add the library with -l or -L: $ gcc -l /usr/lib/libtommath.a main.c /usr/bin/ld: cannot find -l/usr/lib/libtommath.a collect2: ld returned 1 exit status $ gcc -llibtommath.a main.c /usr/bin/ld: cannot find -llibtommath.a collect2: ld returned 1 exit status $ gcc -Llibtommath.a main.c /tmp/ccOxzclw.o: In function `main': main.c:(.text+0x18): undefined reference to `mp_init' collect2: ld returned 1 exit status $ gcc -Llibtommath.a main.c /tmp/ccOxzclw.o: In function `main': main.c:(.text+0x18): undefined reference to `mp_init' collect2: ld returned 1 exit status I am very rusty on this stuff, so I'm not sure I'm using the right command here, in the -L examples are the libraries being found? If the library isn't being found how on earth do I get it to find the library? It's in /usr/lib, I've tried it with the .a file in the current directory, etc. Is there an environment variable I need to set? If so, how, etc. Thanks so much for the help. I've tried a completely different library (GMP) and had the EXACT same problem. This has got to be some kind of Ubuntu environment issue? Anyone have any idea how to fix this?

    Read the article

  • Visual Studio DataSet Designer keep queries

    - by LnDCobra
    In visual studio datasource designer(The screen where you have all the UML Diagrams including relations) is there any way to refresh a table and its relations/foreign key constraints without refreshing the whole table? The way I am doing it at the moment is removing the table and adding it again. This adds all the relations and refreshes all fields. Also if I change a fields data type, is there a way to automatically refresh all the fields in the datasource? Again without deleting the table and adding it again. Reason for this is because some of my TableAdapters have quite a number of complex queries attached to them and when I remove the table the adapter gets removed as well including all its queries. I am using Visual Studio 2008 and connecting to a MySQL database.

    Read the article

  • Keep the session maintain of social networking sites

    - by Rana Muhammad Usman
    I want to develop an application where user will login once from his account he will integrate his social network e.g. facebook, twitter etc. And again he will not be required to login again from his social networking site like the following sites https://seesmic.com and http://hootsuite.com How I can maintain this session. I cant save the access token cz it expires after a certain time kindly tell me how it is possible...........

    Read the article

  • Keep Side Navigation Fixed with Scrolling of page

    - by Stuart Robson
    Hi Guys, I have a clients website - www.stagecraft.co.uk and they want the navigation on the hire pages (longer page) to still be there at when you scroll the page down. I've had a quick go (not live) with position fixed but in doing so it the leftside navigation is about 200px or so from the top of the window. Any when to get it at the top of the window when scrolling? Thanks in advance....

    Read the article

  • How can I keep a hash sorted?

    - by srk
    use strict; use warnings; my @aoh =( { 3 => 15, 4 => 8, 5 => 9, }, { 3 => 11, 4 => 25, 5 => 6, }, { 3 => 5, 4 => 18, 5 => 5, }, { 0 => 16, 1 => 11, 2 => 7, }, { 0 => 21, 1 => 13, 2 => 31, }, { 0 => 11, 1 => 14, 2 => 31, }, ); #declaring a new array to store the sorted hashes my @new; print "\n-------------expected output------------\n"; foreach my $href (@aoh) { #i want a new array of hashes where the hashes are sorted my %newhash; my @sorted_keys = sort {$href->{$b} <=> $href->{$a} || $b <=> $a} keys %$href; foreach my $key (@sorted_keys) { print "$key => $href->{$key}\n"; $newhash{$key} = $href->{$key}; } print "\n"; push(@new,\%newhash); } print "-----------output i am getting---------------\n"; foreach my $ref(@new) { my @skeys = skeys %$ref; foreach my $key (@skeys) { print "$key => $ref->{$key}\n" } print "\n"; } The output of the program : -------------expected output------------ 3 => 15 5 => 9 4 => 8 4 => 25 3 => 11 5 => 6 4 => 18 5 => 5 3 => 5 0 => 16 1 => 11 2 => 7 2 => 31 0 => 21 1 => 13 2 => 31 1 => 14 0 => 11 -----------output i am getting--------------- 4 => 8 3 => 15 5 => 9 4 => 25 3 => 11 5 => 6 4 => 18 3 => 5 5 => 5 1 => 11 0 => 16 2 => 7 1 => 13 0 => 21 2 => 31 1 => 14 0 => 11 2 => 31 Please tell me what am i doing wrong in storing the hashes into a new array.. how do i achieve what i want.. ? Thanks in advance...

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >