Skip to content
🤔prompts chat🧠
🔍
question:I am trying to follow the instructions specified here(http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/O4A_SDK.html) to install OpenCV for Wlipse. The instructions state to open Project Properties -> C/C++ Build, and replace “Build command” text to "{NDKROOT}/ndk-build". However, I don't have a C/C++ section under Project->Properties. I am using Android SDK ADT Bundle for OSX. I have downloaded the NDK and set the NDK location under ADT->Properties->Android->NDK. I have validated that the Android Native Dev Tools and C/C++ Dev Tools are installed. I have imported the project correctly. Why don't I have a C/C++ section under Project->Properties? Next problem. Ok I have found how to add the c/c++ build command thanks to srikanth gr. Now when I try to build the OpenCV Library, I get the following error: "OpenCV.mk: No such file or directory". The current reference in the jni/Android.mk is "include OpenCV.mk". I did a search on my system and no OpenCV.mk file exists. There is a OpenCV.mk.in. Do I need to build that to create the OpenCV.mk? If so, how? Thanks.

answer:It sounds like you're having some issues with setting up OpenCV in your Eclipse project for Android development on OSX. To answer your first question, the reason you're not seeing a C/C++ section under Project->Properties might be because you're using the Android SDK ADT Bundle, which includes only the ADT (Android Development Tools) plugin for Eclipse, and not the CDT (C/C++ Development Tools) plugin. To add CDT to your existing Eclipse installation, you can go to Help > Install New Software, and then add a new software site with the following URL: `http://download.eclipse.org/tools/cdt/releases/8.7` (this URL is for CDT 8.7, which is compatible with Eclipse Kepler). Once you've installed CDT, you should be able to see the C/C++ section under Project->Properties. As for your second question, the `OpenCV.mk` file is typically generated when you build the OpenCV library using the `configure` script. However, if you're using the pre-built OpenCV libraries for Android, you shouldn't need to build the library yourself. Instead, you can use the `OpenCV-2.4.9-android-sdk.tar.bz2` package from the OpenCV website, which includes the `OpenCV.mk` file that you need. Make sure that the `OpenCV.mk` file is in the same directory as your `Android.mk` file. If it's not, you can either move it there or modify the `include` statement in your `Android.mk` file to point to the correct location. If you still can't get it to work, you might want to try following the instructions for setting up OpenCV with Eclipse on OSX that are provided in the official OpenCV documentation: <https://docs.opencv.org/master/d7/d9f/tutorial_linux_eclipse_cv.html>. This guide includes detailed steps for setting up the OpenCV libraries and configuring your Eclipse project.,To add the C/C++ section under Project->Properties, you need to follow these steps: 1. Right-click on your project in the Project Explorer. 2. Go to "Android Tools" -> "Add Native Support". 3. This should add the C/C++ section to your Project Properties. Regarding the "OpenCV.mk: No such file or directory" error, you need to build the OpenCV.mk file. Here's how you can do it: 1. Locate the OpenCV.mk.in file on your system. 2. Rename this file to OpenCV.mk. 3. Open the OpenCV.mk file and make any necessary modifications according to your project requirements. 4. Save the file. 5. Now, you need to build the OpenCV.mk file by running the following command in your terminal: `{NDKROOT}/ndk-build -B -j4 APP_ABI=all`. This command will build the OpenCV.mk file and create the necessary dependencies for your OpenCV Library. Make sure to replace `{NDKROOT}` with the actual path to your NDK installation directory. After successfully building the OpenCV.mk file, you should be able to resolve the "OpenCV.mk: No such file or directory" error and proceed with your OpenCV installation. Let me know if you have any further questions.,The C/C++ build section should be available when you're working with C++ projects. It seems as though when you imported the project, you may have imported it as a Java project instead of a C++ project, this would explain why the C/C++ build section is missing. To resolve this issue you need to change your project type to a C++ project. Here is how you can do it: 1. In Eclipse, go to "File", then "New", then "Other", you will see various project types in the list on the left side of the window. 2. Look for "Android Hello World Project". This is the Android native application type. 3. Click on "Next" and under build entry type, select "C++". 4. Click "Finish". After following these steps, you should now have a C/C++ build section under Project -> Properties. Regarding the second issue, yes, you need to build "OpenCV.mk.in" to create "OpenCV.mk". The ".in" files are typically templates that you need to fill in before they can be used. To do this, follow these steps: 1. Checkout the OpenCV source code. This should contain the necessary "OpenCV.mk.in" file. 2. Run the following command to generate "OpenCV.mk": ``` chmod +x opencv/platforms/android/mk/build.sh ./opencv/platforms/android/mk/build.sh ``` 3. This should generate the "OpenCV.mk" file. Sometimes it can also create some additional ".mk" files as well. Populate these accordingly if your project requires them.

question:How can I display the hash of the current git commit in the browser so that the testing team, who doesn't have access to run Heroku commands, can include the corresponding commit hash in bug reports? I tried using grit, but it doesn't work on Heroku. I also checked the environment variables "COMMIT_HASH" and "LAST_COMMIT_BY" on Heroku, but they are both nil. Is there any way to retrieve the hash information? Can I also get other git information like the commit date?

answer:You can display the hash of the current Git commit in the browser by outputting it as an environment variable during the build process and then reading it in your application. Here's how you can achieve this on Heroku: 1. Create a new file in your project root called `.prebuild` (if you don't have one already) and add the following line to set the environment variable `COMMIT_HASH` when the app is built: ``` echo "COMMIT_HASH=(@git rev-parse HEAD)" >> environment ``` This command sets the `COMMIT_HASH` variable to the HEAD commit hash during the build process. 2. Then, in your application code, read the environment variable and display it in the browser: For a Ruby on Rails app, in your `config/environments/production.rb` add: ```ruby config.after_initialize do Rails.application.routes.default_url_options:host = ENV"WEB_HOST" Rails.application.routes.default_url_options:protocol = "https" Thread.current:commit_hash = ENV.fetch('COMMIT_HASH') { "Unknown" } end ``` And then, in your views you can display it like this: ```erb <p id="commit-hash">Commit Hash: <%= Thread.current:commit_hash %></p> ``` For other languages/frameworks, consult their documentation on how to set and access environment variables accordingly. To get additional Git information, such as the commit date, you can modify the `.prebuild` file like this: ```bash echo "COMMIT_HASH=(@git rev-parse HEAD)" >> environment echo "COMMIT_DATE=(@git show -s --format=%ad HEAD)" >> environment ``` This will set the `COMMIT_DATE` environment variable to the date the last commit was made. Please note, modifying the `.prebuild` file or using similar approaches for setting environment variables may vary depending on the platform your application is deployed to or if you use a different deployment process. Confidence: 90%,If you want to display the commit hash in the console, you can use the GITHUB_SHA environment variable which is automatically set by Heroku. If you want to display it in the browser, you could set it as a Javascript variable by adding a script tag in your HTML like: ```html <script> var commitHash = "{{GITHUB_SHA}}"; </script> ``` The GITHUB_SHA variable contains the SHA of the HEAD commit of the last GitHub push. As for retrieving other git information, you can make use of other environment variables like GIT_COMMIT_MESSAGE, GIT_COMMIT_AUTHOR, and GIT_COMMIT_CREATED_AT, which include information like the commit message, author, and commit date respectively. However, note that these variables may not be available if your app is not linked to a GitHub repository. If you want to get more detailed information (like commit dates), you might have to use a tool like the Heroku Command Line Interface (CLI) or Git locally. Here are instructions for retrieving commit dates using Git: 1. Run the git log command to see the list of commits along with their date. ```bash git log ``` 2. Parse the output of the git log command for the first line that matches the commit hash you want. The commit date will be there. Note: This method requires the use of terminal, which users of your app may not have access to. An alternative solution might involve storing the hash and date information in your database (along with a timestamp if you want to store the date) and then rendering it in your app's UI.,There are a couple of things to consider in this scenario. Firstly, Heroku removes the .git directory during slug compilation, so you won't be able to execute some git commands from inside your app's directory on the Heroku dyno. This includes the commonly used command "git rev-parse HEAD" to get the current commit hash. Secondly, attempting to retrieve information using "git ls-remote" on the Heroku dyno will trigger an SSH connection, resulting in messages like "The authenticity of host 'heroku.com (50.19.85.132)' can't be established" because the Heroku public key is not installed on Heroku dynos. You won't have permission to install the Heroku public key. However, there are still two options you can consider: 1. Add a post-commit hook to update the hash value: a) Create or edit the file ".git/hooks/post-commit". b) Add the following shell script code: ``` hash_name=HEAD_HASH hash=(git rev-parse HEAD) echo "Setting hash_name to hash" heroku config:set hash_name=hash --app yourappname ``` In this script, "HEAD_HASH" is the name of the Heroku environment variable that will store the commit hash. You can customize this name accordingly. The "git rev-parse HEAD" command retrieves the hash of the current commit, which you can display as desired in your application. This approach updates the "HEAD_HASH" environment variable on each commit, but it might be slow as you'll be waiting for Heroku to set the environment variable after each commit. Also, if there are any network issues, the variable won't be updated. There is a possibility that future versions of Git (e.g., 1.8.2) might introduce a "pre-push" hook, which would be a better alternative for this use case. 2. Use a script to push your code: Instead of directly using "git push heroku master" to push your code, you can create a shell script that includes the code from the first option and adds the "git push heroku master" command at the end. By running this shell script, you can update the "HEAD_HASH" only before pushing the code, keeping everything organized in one place. Don't forget to add the script to your ".slugignore" file as well. Both options provide a way to retrieve the commit hash and other desired git information. Choose the one that suits your needs and integration flow the best.

question:I am trying to perform a simple math calculation in my code. Here is what I have: ``` mov al, 128 sub al, -128 ``` I want to know which flags are set by the `sub` instruction. I have an understanding that `sub` is the same as adding the negative of a number. So, starting with the value of `al` being 128, I have the following binary representation: ``` 128 = 0x80 = 1000 0000b ``` Next, I need to get the negative value of 128, which is the two's complement. In other words: ``` 128 = 1000 0000b -128 = 0111 1111b (1's complement) + 1 = 1000 0000b ``` So, I now have the same number, but in its negative form. Now, I need to add these two numbers together because that's what the `sub` instruction does, instead of performing real subtraction. The final result would be: ``` 1000 0000b + 1000 0000b ---------- 10000 0000b ``` This indicates that the following flags are set: `CF` (there is a carry), `ZF` (AL is 0), and `PF` (even number of 1's from d0 to d3). However, when I run the same code: ``` mov al, 128 sub al, -128 ``` It only sets the `ZF` and `PF` flags, but not the `CF`. Can someone explain why? What am I doing wrong?

answer:In the original code provided (`mov al, 128` followed by `sub al, -128`), you correctly performed the calculation and arrived at a sum of `1000 0000b` in the AL register. Note that this is not the same as a binary value of 1 (one digit of 1s), but rather the implied binary point at the least significant end of the register. When you manually perform the `sub` operation as an addition, you correctly calculate a sum of 256, which requires a value of 128 in AL before the operation, and a carry from bit 7 (which is the `CF` flag). However, when you perform the same calculations in machine code, the processor is performing signed arithmetic, and expects the value provided to `sub` to be a signed number, which -128 is. As a two's complement integer, -128 is equal to `128` in decimal and `1000 0000b` in binary. The processor performs the calculation without generating a carry out of the most significant bit. In other words, the behavior you're seeing is correct and expected due to the fact that the computer is performing signed arithmetic. It is subtracting a signed `-128` from an unsigned `128`, resulting in a negative number. The `CF` flag is not set because there was no carry from the most significant bit.,In the context of the CPU, the idea that `sub` is the same as adding the negative of a number is not accurate. The processor treats both numbers as equal values and performs the subtraction accordingly. The fact that you, as a human, understand that the second number is negative does not affect the processor's behavior. Since both numbers are equal, no borrow is needed and the `CF` flag remains unset., You are correct in your understanding of how the `sub` instruction works and how the flags are affected by it. However, you have made a mistake in calculating the result of the subtraction. The correct calculation is: 1000 0000b (128) - 1111 1111b (-128) ----------------- 0000 0001b (1) So the result of the subtraction is 1, not 0. Therefore, the carry flag (CF) is not set, because there is no carry out from the most significant bit. The zero flag (ZF) is set because the result is zero. The parity flag (PF) is set because the number of 1s in the low-order byte of the result (which is just a single 1) is even. In summary, the correct flags that are set are ZF and PF, but not CF. You were correct in your calculation of the flags, except for the CF flag.

question:I have a MySQL server installed in X.X.60.X and I am trying to access it through JDBC from X.X.80.X. I am able to connect to the server successfully using MySQL workbench, but when I try to connect through my program, I get the following error message: "java.sql.SQLException: Access denied for user 'user'@'X.X.80.X' (using password: NO)". I have already given all privileges to 'user'@'X.X.80.X' in the server. What could be causing this issue?

answer:Based on the error message you're seeing, it seems like the issue is related to authentication rather than connectivity. Even though you've granted all privileges to the user 'user'@'X.X.80.X', the error message indicates that the connection is being attempted without a password (using password: NO). Here are a few things you can check: 1. Make sure that you're specifying the correct password in your JDBC connection string. The format should be something like this: ```bash jdbc:mysql://X.X.60.X:3306/database_name?user=user&password=password ``` 2. Double-check that the user account has been created with the correct IP address and password. You can do this by running the following command in the MySQL console: ```sql SELECT user, host, password FROM mysql.user; ``` This will show you a list of all user accounts and their associated host and password hashes. Make sure that the 'user'@'X.X.80.X' account has the correct password hash. 3. Check the grant table to ensure that the user has the correct privileges. You can do this by running the following command in the MySQL console: ```sql SHOW GRANTS FOR 'user'@'X.X.80.X'; ``` This will show you the privileges that have been granted to the 'user'@'X.X.80.X' account. Make sure that the account has the necessary privileges to access the database. 4. Make sure that there are no firewalls or security groups blocking incoming traffic on the MySQL port (3306) from the IP address X.X.80.X. I hope this helps! Let me know if you have any further questions.,The error message "java.sql.SQLException: Access denied for user 'user'@'X.X.80.X' (using password: NO)" suggests that the program is attempting to connect to the MySQL server without providing a password for the user 'user'. This could be the reason for the access denied error. To resolve this issue, you need to ensure that the password for the user 'user' is set in your MySQL server. Here's an example of how you can modify your program to include the password: ```java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class MySQLConnection { public static void main(String args) { String url = "jdbc:mysql://X.X.60.X:3306/database"; String username = "user"; String password = "your_password"; // Replace with the actual password try { Connection connection = DriverManager.getConnection(url, username, password); System.out.println("Connected to MySQL server successfully!"); // Perform your database operations here connection.close(); } catch (SQLException e) { System.out.println("Error connecting to MySQL server: " + e.getMessage()); } } } ``` In the above example, make sure to replace "your_password" with the actual password for the user 'user' in your MySQL server. By providing the correct password in the program, you should be able to connect to the MySQL server without encountering the access denied error.,The error message you're receiving suggests that MySQL is denying access for the user 'user'@'X.X.80.X' (using password: NO). The reason you are still getting this error could be due to a couple of reasons: 1. The specified password is incorrect: Even though you mentioned you're not using a password, it might be possible that a default password is used or there is a misprint in the username/password. Check the credentials and ensure they are correct. 2. A timeout issue: Check your MySQL settings and ensure they are not blocking your access. 3. Firewall settings: Ensure that the firewall on both your MySQL server and your development machine are allowing connections on the necessary ports. 4. Incorrect URL: Check the URL you are using to connect to the MySQL server is correct. You can solve this problem by checking your username, password, firewall settings, and URL. Remember to re-test your connection after each change to ensure you have located and resolved the issue. Please remember that my instructions are based on information provided, but it is always best to check for any error messages while troubleshooting. Also, because this topic includes both software and server admin, it may be necessary to consult MySQL's official documentation and community forums for a comprehensive understanding of the problem and its possible solutions.

Released under the wen License.

has loaded